How to fix this ArrayAdapter requires the resource ID to be a TextView

后端 未结 3 1776
离开以前
离开以前 2021-01-29 08:47

I am new to android, I\'m trying to develop an application with gridview and listview using json. Through json I displayed set of images in gridview and based on the position of

3条回答
  •  星月不相逢
    2021-01-29 09:28

    Since you are using the default ListView and ArrayAdapter, and you have only one data list, ie SubCatgyData, you should be using android.R.layout.simple_list_item_1 instead of android.R.layout.simple_list_item_2.

    The difference between the two is android.R.layout.simple_list_item_1 has only one TextView inside it, while android.R.layout.simple_list_item_2 has two TextView.

    ArrayAdapter adapter = new ArrayAdapter(Sub_Categories.this,android.R.layout.simple_list_item_1,SubCatgyData);
    

提交回复
热议问题