0
私は、ListViewコントロールはまだチャイルズを持っていないので、それは動作しませんListActivity)(の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
}
ののonCreate()メソッドの最後にこのコードを置く - それはサイズ0です。ただし、.getAdapter()。getCount()は0を返しません。
このコードを正しく作成するために、list.getChildAt(i)の代わりに何を使用しますか?
UPDATE:私は、これは私がFormatting ListView Content During onCreate() method (getting ListView children) 必要なものだと思いますが、取得するにはlist.getChildAt(i)
使用lv.getAdapter().getView(i, null, null)
の代わりに、私はビューをアダプタに追加された問題
ので、私はこれに自分のコードを変更: 'のために(。。I = 0をint型、iがgetListViewを(<)getAdapter()同様にgetCount(); iが++){ \tのTextViewテレビ=(のTextView)list.getAdapter( ).getView(i、null、null).findViewById(R.id.list_item);。 tv.setTextColor(Color.RED); } ' それはコンパイルされますが、何もしません。 – user1049280
カスタムアダプターとgetView()メソッドの方がうまく作成できます。 –
ok、ご協力いただきありがとうございます – user1049280