1
내가 문제가이 각 값을 보여 루핑 는 ArrayList의 각 텍스트 뷰 안드로이드
totalCardPerPage = 30;
cardNumber = 1;
//looping to determine textView id in my xml
for(int x=1;x<=totalCardPerPage;x++){
//textView id
textId = "text"+cardNumber;
int id = getResources().getIdentifier(textId, "id", "com.example.radioexample");
TextView currcell = (TextView) findViewById(id);
//get array size
int arrayListSize = arrayListPage1.size();
//looping to show each value in textView
for(int y=0; y<=arrayListSize; y++){
currcell.setText(arrayListPage1.get(y).toString);
currcell.setBackgroundColor(Color.RED);
}
cardNumber++;
}
텍스트 뷰
을 수동으로 작성 또는 고정 각 텍스트 뷰에 내 ArrayList의 각 값을 표시하기 위해 노력하고있어 각각의 값을 표시 textView. 내 배열의 모든 값은 하나의 텍스트 뷰에 모여,이 코드내가 ArrayList를 루핑을 위해 그것을 실현을 실행할 때
나는 오류를 가지고에만
5 값이있는 경우 그것이 있어야 내 배열, 각 값은 각 textView에 표시됩니다. 예를 들어
,arraylist {a,b,c,d,e};
text1.setText(a);
text2.setText(b);
text3.setText(c);
text4.setText(d);
text5.setText(e);
사람이 그것을 어떻게 알아?
감사
동적으로 만들고 textviews 상위 레이아웃으로 –
@jitainsharma이 경우 수동으로 작성하거나 고정 된 textView를 작성해야합니다. – user3553370
할 수있는 일은 textview로만 레이아웃을 작성하고 각 for 루프에서이 레이아웃을 확장 한 다음 주 레이아웃 상위 뷰에 추가하는 것입니다. –