arrayAdapter only returning one position, Android

I set the arrayList to 12 items, however the arrayAdapter only returns one item on the screen, why is this? It is supposed to show 12 items on the list.

  public class MainActivity extends Activity {

ArrayList<CheckBoxInfo> cfo = new ArrayList<CheckBoxInfo>();
CheckBoxInfo cbr;
private ListAdapter MyAdapter;
ListView listview;
MyAdapter myAdapter;

protected void onCreate(Bundle savedInstanceState) {

    cbr = new CheckBoxInfo();
    cbr.checkBoxName = "dfdjklfjdkljf";
    cbr.checkBoxState = true;

      for(int i = 0; i <12; i++){

      Toast.makeText(MainActivity.this, "size: " + cfo.size(), Toast.LENGTH_SHORT).show();

    listview = (ListView) findViewById(;
    myAdapter = new MyAdapter(cfo, this);

public class MyAdapter extends ArrayAdapter<CheckBoxInfo> {

    private List<CheckBoxInfo> checkBoxList;
    private Context context;

    public MyAdapter(List<CheckBoxInfo> infoList, Context context) {
        super(context, R.layout.row_layout, infoList);
        this.checkBoxList = infoList;
        this.context = context;


    public View getView(int position, View convertView, ViewGroup parent) {

        // First let's verify the convertView is not null
        if (convertView == null) {
            // This a new view we inflate the new layout
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.row_layout, parent, false);
            // Now we can fill the layout with the right values
            TextView tv = (TextView) convertView.findViewById(;
            CheckBox cb = (CheckBox) convertView.findViewById(;
            CheckBoxInfo cbi = checkBoxList.get(position);

              Toast.makeText(MainActivity.this, "position: " + position, Toast.LENGTH_SHORT).show();


        return convertView;

}  // end MyAdapter


  • WebView images are not showing with HTTPS
  • How many items a ListView can store?
  • How to execute Async task repeatedly after fixed time intervals
  • RecyclerView LayoutManager different span counts on different rows
  • How to Parse Date from GMT TimeZone to IST TimeZone and Vice Versa in android
  • Menu Tabs Don't Respond
  •   <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android=""
         android:orientation="horizontal" >
        android:text=" " />
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    Related posts:

    Hyphenation in Android
    How can my view respond to a mousewheel?
    Cannot find any Android targets in this SDK in IntelliJ 2016
    How to get class name only, not full path?
    Cancel a toast on Android before it appears
    How to install last version of ADT plug-in for eclipse
  • java.lang.NoClassDefFoundError $$inlined$forEach$lambda$1 in Kotlin
  • How to adjust layout when soft keyboard appears
  • Permission issue while starting a service from android
  • openOptionsMenu() will not work in appcompat-v7 22.1.0 or newer
  • Crop square image to circle - Programmatically
  • Android NDK incremental build
  • 4 Solutions collect form web for “arrayAdapter only returning one position, Android”

    found out that the problem was the ListView was inside a ScrollView in the xml Layout, once i removed the outer ScrollView all the items of the ListView showed up.

    for some reason if you encapsulate a ListView nested in several layers it will show only one position item if the ListView in inside a ScrollView

    Override getCount in your MyAdapter

    public int getCount() {
       return infoList == null ? 0 : infoList.size();

    Please show code of row_layout, I think your error is for loop:

    Try create 2 checkboxs and add manual to test:

    cbr1 = new CheckBoxInfo();
    cbr1.checkBoxName = "checkbox1";
    cbr1.checkBoxState = true;
    cbr2 = new CheckBoxInfo();
    cbr2.checkBoxName = "checkbox2";
    cbr2.checkBoxState = true;

    I had this problem because my notifyDataSetChanged() was inside a loop and wasn’t being called in certain circumstances (if there were no data items).

    Make sure notifyDataSetChanged() is getting called when it should be!

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.