首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法实例化类型ExpandableListAdapter

无法实例化类型ExpandableListAdapter
EN

Stack Overflow用户
提问于 2013-10-21 12:30:15
回答 3查看 6K关注 0票数 1

我试图在导航抽屉中创建一个ExpandableListView。我尝试了一个示例代码,但在编译之前得到了这个错误。

代码语言:javascript
复制
public class MainActivity extends Activity {

     ExpandableListAdapter listAdapter;
    ExpandableListView expListView;
    List<String> listDataHeader;
    HashMap<String, List<String>> listDataChild;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // get the listview
        expListView = (ExpandableListView) findViewById(R.id.left_drawer);

        // preparing list data
        prepareListData();

   listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);

错误在这一行中: listAdapter =( this,listDataHeader,listDataChild);

为什么它说不能实例化类型ExpandableListAdapter?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-10-21 12:38:18

ExpandableListAdapter也是android.widget.ExpandableListAdapter中的一个接口,您似乎正在导入它,这是试图实例化本地ExpandableListAdapter类。

重命名你的ExpandableListAdapter

票数 10
EN

Stack Overflow用户

发布于 2015-08-19 10:42:05

删除import android.widget.ExpandableListAdapter;或用此名称重命名类。

:)

票数 2
EN

Stack Overflow用户

发布于 2013-10-21 12:36:06

因为ExpandableListAdapter是一个interface,所以aka没有实现。

查看文档,了解ExpandableListAdapter的一些实现,如SimpleExpandableListAdapter

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19494572

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档