2011-04-27 35 views
0

我正在動態創建Expandablelistview,如下所示,其中展開列表包含edittext和複選框。Android動態添加Expandablelistview返回null爲findviewbyid

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

我的一個FRND做了一個很好的教程選中此[鏈接](http://coderzheaven.com/index.php/2011/04/expandable-listview-in-android-using-simpleexpandablelistadapter-a -simple-example /) – 2011-04-27 15:29:16

回答

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); 
+0

添加布局參數來設置寬度和高度 – 2011-12-09 08:54:47