android - assign arraylist value to textview -
i'm trying set value arraylist textview
arraylist<integer> arraylistpage1, arraylistpage2, arraylistpage3, arraylistpage4, arraylistpage5; arraylistpage1 = new arraylist<integer>(rangemode); arraylistpage2 = new arraylist<integer>(rangemode); arraylistpage3 = new arraylist<integer>(rangemode); arraylistpage4 = new arraylist<integer>(rangemode); arraylistpage5 = new arraylist<integer>(rangemode); totalcardinpage = new int[totalpage+1]; for(int j=1;j<=totalpage;j++){ int x=0; for(int i=1;i<=rangemode;i++){ if(binarytable[i][j]==1){ //maka ada di page j cardinpage[j][x]=i; //array buat card di page 1 if (j==1){ arraylistpage1.add(i); }else if(j==2){ arraylistpage2.add(i); }else if(j==3){ arraylistpage3.add(i); }else if(j==4){ arraylistpage4.add(i); }else if(j==5){ arraylistpage5.add(i); } x++; } } system.out.println("page-"+j+" jumlah kartu:"+x); totalcardinpage[j]=x; } system.out.println("list page 1 "+arraylistpage1); system.out.println("list page 2 "+arraylistpage2); system.out.println("list page 3 "+arraylistpage3); system.out.println("list page 4 "+arraylistpage4); system.out.println("list page 5 "+arraylistpage5); textview text1 = (textview) findviewbyid(r.id.text1); if (arraylistpage1[0]!=null){ text1.settext(arraylistpage1[0]); } else{ text1.setvisibility(view.gone); } if (arraylistpage1[1]!=null){ text1.settext(arraylistpage1[1]); } else{ text1.setvisibility(view.gone); }
but got error when i'm trying set arraylist value textview. error said because i'm using arraylist cannot assign value textview
anyone know how fix this?
thanks
it happens because set integer value textview , textview finds string resources. convert integer value string.
for example:
text1.settext(arraylistpage1.get(0).tostring());
or simple:
text1.settext(arraylistpage1.get(0) + "");
Comments
Post a Comment