How To Fix This Arrayadapter Requires The Resource Id To Be A Textview
Solution 1:
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.
ArrayAdapteradapter=newArrayAdapter(Sub_Categories.this,android.R.layout.simple_list_item_1,SubCatgyData);
Solution 2:
You need to override [ArrayAdapter.getView(int, View, ViewGroup)](http://developer.android.com/reference/android/widget/ArrayAdapter.html#getView(int, android.view.View, android.view.ViewGroup)). See http://developer.android.com/reference/android/widget/ArrayAdapter.html
To use something other than TextViews for the array display, for instance, ImageViews, or to have some of data besides toString() results fill the views, override getView(int, View, ViewGroup) to return the type of view you want.
Solution 3:
Create your custom layout for adapter. You are using one provided by android. See the android prefix you are using for your layout.
Post a Comment for "How To Fix This Arrayadapter Requires The Resource Id To Be A Textview"