0
내가에서 onCreate() 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
}
의 ListView가 아직 차일이 없기 때문에 작동하지 않습니다 - 그것의 크기 0; 그러나 .getAdapter(). getCount()는 0이 아닙니다.
이 코드를 올바르게 작성하려면 list.getChildAt (i) 대신 무엇을 사용해야합니까?
UPDATE : 내가 생각이 내가 Formatting ListView Content During onCreate() method (getting ListView children) 필요하지만 난이를 얻기 위해
그래서 나는이 내 코드를 변경 : 가'에 대한 (I = 0 int로, 내가 ++; 내가 위에서 getListView() 대해 getAdapter() getCount()를 <..() { \t 텍스트 뷰의 TV = (텍스트 뷰) list.getAdapter를) .getView (i, null, null) .findViewById (R.id.list_item); tv.setTextColor (Color.RED); } ' 컴파일하지만 아무 것도하지 않습니다. – user1049280
사용자 정의 adapeter와 내부 getView() 메소드를 더 잘 작성하십시오. –
확인해 주셔서 감사합니다. – user1049280