0
後更新的細胞內視我ListViewActivityAndroid的列表式視圖。只是無效活動的看法
public class SelectActivity extends ListActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.select_one_of);
SimpleAdapter adapter = new SimpleAdapter(
this,
createChildList(),
R.layout.select_one_of_childrow,
new String[] { KEY_VALUE },
new int[] { R.id.selectoneof_add_new_item});
setListAdapter(adapter);
}
// ...
}
setListAdapter後()調用我想執行以下代碼:
((TextView) getListView().getChildAt(0).findViewById(R.id.selectoneof_add_new_item)).setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ticked, 0);
但getListView()。 getChildAt(xxx)返回null,並捕獲NullPointerException。我應該在哪裏提到上面的代碼片段?
我不相信這個!我仍然希望它可以簡單地完成,而無需編寫自己的/自定義ListAdapter – davs 2010-05-15 15:29:10
恕我直言,「編寫自己的/自定義的ListAdapter」比您提議的更簡單也更可靠。 – CommonsWare 2010-05-15 18:13:24
...但我不想在每個listView渲染過程中檢查...我需要在Activity的開始時執行一次操作... – davs 2010-05-15 20:07:59