Android 当我的类扩展ExpandableListActivity时如何获取supportactionbar
我有一个类扩展了Android 当我的类扩展ExpandableListActivity时如何获取supportactionbar,android,android-actionbar,android-support-library,android-actionbar-compat,Android,Android Actionbar,Android Support Library,Android Actionbar Compat,我有一个类扩展了ExpandableListActivity以可解释列表视图的形式显示我的数据,现在我的应用程序支持旧版本,直到API 7如何使用getSupportActionBar()将ActionBar添加到此类…请帮助我 public class Facts extends ExpandableListActivity { public void onCreate(Bundle savedInstanceState) { try{ super.onCreat
ExpandableListActivity
以可解释列表视图的形式显示我的数据,现在我的应用程序支持旧版本,直到API 7如何使用getSupportActionBar()
将ActionBar
添加到此类…请帮助我
public class Facts extends ExpandableListActivity {
public void onCreate(Bundle savedInstanceState) {
try{
super.onCreate(savedInstanceState);
setContentView(R.layout.facts);
SimpleExpandableListAdapter expListAdapter =
new SimpleExpandableListAdapter(
this,
createGroupList(), // Creating group List.
R.layout.facts_grouprow, // Group item layout XML.
new String[] { "questions" }, // the key of group item.
new int[] { R.id.row_name }, // ID of each group item.-Data under the key goes into this TextView.
createChildList(), // childData describes second-level entries.
R.layout.facts_childrow, // Layout for sub-level entries(second level).
new String[] {"answers"}, // Keys in childData maps to display.
new int[] { R.id.grp_child} // Data under the keys above go into these TextViews.
);
setListAdapter(expListAdapter); // setting the adapter in the list
}catch(Exception e){
System.out.println("Errrr +++ " + e.getMessage());
}
}
现在建议我如何实现它。看看,似乎很容易在您自己的类中复制相同的功能,并将其扩展为其基类。我建议您使用。这就是你的方法 要显示您的
可扩展列表
,您可以从support-v4库中添加一个。
有一个名为setListAdapter()
的方法,您可以在其中添加一个
您是说我必须编写自定义适配器并将其扩展到BaseExpandableListAdapter以实现ha。请您详细说明我的问题上下文,因为我已经编辑了我的问题,也提供了链接,前提是您作为示例不使用列表片段,它只是使用了扩展BaseExpandableListAdapter的自定义适配器我添加了这个示例,因为我不知道您是否已经使用了
片段。您还可以将您的SimpleExpandableListAdapter
添加到setListAdapter
,这样您就不必编写自定义的ExpandableListAdapter
。如果我解释错误,请纠正我。您是说我的Facts
类应该扩展ActionBarActivity
,从它调用一个扩展了ListFragment
的片段,在ListFragment
中,我可以使用SimpleExpandableListAdapter
到setListAdapter
ok@owe让我这样做,如果工作正常,请接受您的答案……谢谢您的建议