我有一个扩展ExpandableListActivity
的类来显示我的数据作为可解释列表视图,现在我的应用支持旧版本,直到API 7如何使用ActionBar
向此类添加getSupportActionBar()
。 ..请帮帮我
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());
}
}
现在建议我如何实现它。
答案 0 :(得分:2)
查看ExpandableListActivity source code,似乎很容易在您自己的类中复制相同的功能并将其扩展为ActionBarActivity
作为其基类。
答案 1 :(得分:1)
我建议你使用ActionBarActivity
。你有方法getSupportActionBar
。
要显示您的ExpandableList
,您可以从support-v4 lib添加ListFragment
。
有一种名为setListAdapter()
的方法,您可以在其中添加ExpandableListAdapter
。