0
我把这个代码的onCreate()ListActivity的方法结束得到的ListView孩子的onCreate()
ListView list=getListView();
for (int i=0;i<list.getAdapter().getCount();i++) {
TextView tv= (TextView) list.getChildAt(i).findViewById(R.id.list_item);
tv.setTextColor(Color.RED); //i simplify this string for example
}
这是行不通的,因为ListView中没有孩子的,但 - 它的大小为0;但.getAdapter()。getCount()返回不为0.
我应该用什么来代替list.getChildAt(i)来使此代码正确?
更新:我想,这是我需要的Formatting ListView Content During onCreate() method (getting ListView children) 但我不明白这个问题
所以我改变码本: '为(INT I = 0; I
user1049280
2011-12-23 14:14:27
更好的创建你的自定义adapeter和getView()方法。 – 2011-12-23 14:29:49
好的,谢谢你的帮助 – user1049280 2011-12-23 14:33:53