Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 当我的类扩展ExpandableListActivity时如何获取supportactionbar_Android_Android Actionbar_Android Support Library_Android Actionbar Compat - Fatal编程技术网

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让我这样做,如果工作正常,请接受您的答案……谢谢您的建议