android - Iterate ListView -


i have listview using custom baseadapter. can see elements right in screen. in point, need access different views of listview.

i got 4 element when run listview.getcount() , 0 elements listview.getchildcount(). have tried listview.getchildat() 0.

what doing wrong?

thanks.

for(int nviews = 0; nviews < liststudents.getcount(); nviews++) {      view childlistview = liststudents.getchildat(nviews);     if(childlistview != null) {         imageview childimage = (imageview) childlistview.findviewbyid(r.id.firststudentbutton);         if(childimage.gettag() == decnumber) {             log.d("searching", "find");             liststudents.setselection(nviews);         }     }  }  <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:layout_marginleft="40dp"     android:layout_marginright="10dp"     android:orientation="horizontal" > <linearlayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"     android:layout_marginright="40dp"       android:layout_marginleft="20dp"     >     <imageview          android:id="@+id/firststudentimage"         android:contentdescription="@string/test"         android:maxwidth="250dp"             android:maxheight="150dp"         android:layout_width="81dp"         android:layout_height="115dp"         >     </imageview>     <textview         android:id="@+id/firststudentname"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="22sp"         android:textisselectable="false">     </textview>      <button         android:id="@+id/firststudentbutton"         android:layout_width="81dp"         android:layout_height="wrap_content"         android:background="@color/attendance_no_data"         android:textcolor="@color/settings_text_color"         android:text="@string/attendance_no_data" >     </button> </linearlayout>      <linearlayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:layout_marginright="40dp"        android:orientation="vertical">     <imageview          android:id="@+id/secondstudentimage"         android:contentdescription="@string/test"         android:maxwidth="250dp"             android:maxheight="150dp"         android:layout_width="81dp"         android:layout_height="115dp"         >     </imageview>     <textview         android:id="@+id/secondstudentname"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="22sp"         android:textisselectable="false">     </textview>     <button         android:id="@+id/firststudentbutton"         android:layout_width="81dp"         android:layout_height="wrap_content"         android:background="@color/attendance_no_data"         android:textcolor="@color/settings_text_color"         android:text="@string/attendance_no_data" >     </button> </linearlayout>      <linearlayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:layout_marginright="40dp"       android:orientation="vertical">     <imageview          android:id="@+id/thirdstudentimage"         android:contentdescription="@string/test"         android:maxwidth="250dp"             android:maxheight="150dp"         android:layout_width="81dp"         android:layout_height="115dp"         >     </imageview>     <textview         android:id="@+id/thirdstudentname"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="22sp"         android:textisselectable="false">     </textview>     <button         android:id="@+id/firststudentbutton"         android:layout_marginleft="25dp"         android:layout_width="81dp"         android:layout_height="wrap_content"         android:background="@color/attendance_no_data"         android:textcolor="@color/settings_text_color"         android:text="@string/attendance_no_data" >     </button> </linearlayout>              <linearlayout                 android:layout_width="match_parent"                 android:layout_height="match_parent"                 android:layout_marginright="40dp"                   android:orientation="vertical">     <imageview          android:id="@+id/fourthstudentimage"         android:contentdescription="@string/test"         android:maxwidth="250dp"             android:maxheight="150dp"         android:layout_width="81dp"         android:layout_height="115dp"         >     </imageview>     <textview         android:id="@+id/fourthstudentname"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="22sp"         android:textisselectable="false">     </textview>     <button         android:id="@+id/firststudentbutton"         android:layout_marginleft="25dp"         android:layout_width="81dp"         android:layout_height="wrap_content"         android:background="@color/attendance_no_data"         android:textcolor="@color/settings_text_color"         android:text="@string/attendance_no_data" >     </button> </linearlayout>                      <linearlayout                     android:layout_width="match_parent"                     android:layout_height="match_parent"                     android:layout_marginright="40dp"     android:orientation="vertical">     <imageview          android:id="@+id/fivethstudentimage"         android:contentdescription="@string/test"         android:maxwidth="250dp"             android:maxheight="150dp"         android:layout_width="81dp"         android:layout_height="115dp">     </imageview>     <textview         android:id="@+id/fivethstudentname"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="22sp"         android:textisselectable="false">     </textview>     <button         android:id="@+id/firststudentbutton"         android:layout_marginleft="25dp"         android:layout_width="81dp"         android:layout_height="wrap_content"         android:background="@color/attendance_no_data"         android:textcolor="@color/settings_text_color"         android:text="@string/attendance_no_data" >     </button> </linearlayout>  <linearlayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:layout_marginright="40dp"     android:orientation="vertical">     <imageview          android:id="@+id/sixthstudentimage"         android:contentdescription="@string/test"         android:maxwidth="250dp"             android:maxheight="150dp"             android:layout_width="81dp"         android:layout_height="115dp">     </imageview>     <textview         android:id="@+id/sixthstudentname"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="22sp"         android:textisselectable="false">     </textview>     <button         android:id="@+id/firststudentbutton"         android:layout_marginleft="25dp"         android:layout_width="81dp"         android:layout_height="wrap_content"         android:background="@color/attendance_no_data"         android:textcolor="@color/settings_text_color"         android:text="@string/attendance_no_data" >     </button> </linearlayout> 


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -