android - ListView Adapter calling getView with the same index 3 times despite there being 17 items in arraylist -


as title says, adapter doesn't work. i've given arraylist of string arrays. arraylist contains 17 string arrays. result should 17 rows in list view. alas, fails me.

@override     public view getview(int index, view arg1, viewgroup parent) {         layoutinflater inflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service);         view view = inflater.inflate(r.layout.courses_list, parent, false);     textview modulecode = (textview) view.findviewbyid(r.id.modulecode);     modulecode.settext(list.get(index)[0]);      log.i("list-get", integer.tostring(index));      textview modulename = (textview) view.findviewbyid(r.id.modulename);     modulename.settext(list.get(index)[1]);      textview modulecredits = (textview) view.findviewbyid(r.id.modulecredits);     modulecredits.settext(list.get(index)[2]);      checkbox c = (checkbox) view.findviewbyid(r.id.modulecheck);     c.setchecked(true);      return view; } 

this logcat outputs:

04-29 17:31:13.818  14509-14509/com.example.thing i/list-get﹕ 0 04-29 17:31:13.830  14509-14509/com.example.thing i/list-get﹕ 0 04-29 17:31:13.834  14509-14509/com.example.thing i/list-get﹕ 0 

this listview looks in xml (with match_parent added):

<listview         android:layout_width="match_parent"         android:layout_height="match_parent"         android:id="@+id/listview"         android:padding="10dp"         android:layout_below="@+id/yearspinner"         android:layout_alignparentleft="true"         android:layout_alignparentstart="true" /> 

whatsagowinown?

edit: requested, xml contains listview

<scrollview xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent" >      <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:tools="http://schemas.android.com/tools"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:paddingbottom="@dimen/activity_vertical_margin"         android:paddingleft="@dimen/activity_horizontal_margin"         android:paddingright="@dimen/activity_horizontal_margin"         android:paddingtop="@dimen/activity_vertical_margin"         tools:context=".courseselection"  >          <textview             android:id="@+id/title"             android:textsize="70sp"             android:textcolor="@color/dark_grey"             android:text="@string/course_select_title"             android:padding="10dp"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_alignparenttop="true"             android:layout_centerhorizontal="true" />          <spinner             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:id="@+id/departmentspinner"             android:padding="10dp"             android:layout_below="@+id/title"             android:layout_alignparentleft="true"             android:layout_alignparentstart="true"             android:spinnermode="dialog" />          <spinner             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:id="@+id/coursespinner"             android:padding="10dp"             android:layout_below="@+id/departmentspinner"             android:layout_alignparentright="true"             android:layout_alignparentend="true"             android:spinnermode="dialog" />          <spinner             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:id="@+id/yearspinner"             android:padding="10dp"             android:layout_below="@+id/coursespinner"             android:layout_alignparentright="true"             android:layout_alignparentend="true"             android:spinnermode="dialog" />          <listview             android:layout_width="match_parent"             android:layout_height="match_parent"             android:id="@+id/listview"             android:padding="10dp"             android:layout_below="@+id/yearspinner"             android:layout_alignparentleft="true"             android:layout_alignparentstart="true" />           <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_below="@id/listview"             android:orientation="vertical"             android:layout_margintop="45dp" >              <gridlayout                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:columncount="4"                 android:rowcount="2"                 android:layout_gravity="center_horizontal" >                  <button                     android:id="@+id/bcancel"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_column="0"                     android:layout_row="0"                     android:layout_gravity="center"                     android:background="@drawable/cancel"                     android:layout_marginright="34dp" />                  <button                     android:id="@+id/bconfirm"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_column="1"                     android:layout_row="0"                     android:layout_gravity="center"                     android:background="@drawable/signin"/>                  <textview                     android:id="@+id/tcancel"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_column="0"                     android:layout_row="1"                     android:textappearance="?android:attr/textappearancesmall"                     android:layout_gravity="center"                     android:text="@string/cancel"                     android:layout_marginright="34dp"                     android:paddingtop="17dp"/>                  <textview                     android:id="@+id/tconfirm"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_column="1"                     android:layout_row="1"                     android:textappearance="?android:attr/textappearancesmall"                     android:layout_gravity="center"                     android:text="confirm"                     android:paddingtop="17dp"                     android:focusable="false"/>              </gridlayout>          </linearlayout>      </relativelayout> </scrollview> 

edit 2: , xml adapter:

<?xml version="1.0" encoding="utf-8"?> <gridlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:columncount="2"     android:id="@+id/courses_list"     android:background="#ffffff"     android:focusable="false" >      <textview         android:id="@+id/modulecode"         android:layout_row="0"         android:layout_column="1"         android:layout_gravity="center_horizontal|left"         android:text="xx12345"         android:textappearance="?android:attr/textappearancelarge"         android:layout_margin="10dp"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textcolor="#000000" />      <textview         android:id="@+id/modulename"         android:layout_row="1"         android:layout_column="1"         android:layout_gravity="center_horizontal|left"         android:textcolorhighlight="@color/grey"         android:text="module name here"         android:layout_margin="10dp"         android:paddingbottom="10dp"         android:textappearance="?android:attr/textappearancelarge"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textcolor="#000000" />      <textview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textappearance="?android:attr/textappearancemedium"         android:text="credits"         android:layout_margin="10dp"         android:layout_gravity="center_horizontal|right"         android:id="@+id/modulecredits"         android:layout_row="0"         android:layout_column="1" />      <checkbox         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="taking?"         android:id="@+id/modulecheck"         android:layout_gravity="center_horizontal|right"         android:layout_row="1"         android:layout_margin="10dp"         android:layout_column="1"         android:checked="false" />  </gridlayout> 


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -