Android动态添加Expandablelistview为findviewbyid返回null

时间:2011-04-27 15:16:36

标签: android null expandablelistview

我正在动态创建Expandablelistview,如下所示,展开的列表包含edittext和checkbox。

ExpandableListView epView = new ExpandableListView(this);
mAdapter = new MyExpandableListAdapter();
epView.setAdapter(mAdapter);
LinearLayout ll = (LinearLayout) findViewById(R.id.myLayout);
ll.addView(epView);

我的LinearLayout ll中有一个提交按钮提交我试图使用edittext id获取可扩展列表中的值。我获取了移动屏幕中显示的展开项目的值,但是对于findviewbyid,折叠状态项目返回null。有人能为我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

              ExpandableListView epView = new ExpandableListView(this);
              LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(200,200);

              mAdapter = new MyExpandableListAdapter();
              epView.setAdapter(mAdapter);
              LinearLayout ll = (LinearLayout) findViewById(R.id.myLayout);
              ll.addView(epView,lp );