Reputation: 1575
hi I created one simple xml based spinner application.i got all value in my xml file using sax parser. I have two spinner and one grid view, the 1st spinner display one array list value 2nd spinner display one array list. The same time grid view display some images in bottom. this process working fine. now i wish to create text with images spinner so i used row.xml file in my resource folder and i change my code also but i am getting error. what mistake i made in my code.....
error line:
label.setText(hltag_List[position]);
Upvotes: 0
Views: 7693
Reputation: 29199
please see you are using arraylist in constructor
public MyAdapter(Context context, int textViewResourceId, ArrayList<String> hltagList) {
super(context, textViewResourceId, hltagList);
}
whereas accessing its elements via array. just change your line to
label.setText(hltag_List.get(position));
Change your adapter code to following if, you have an array in datasource:
public MyAdapter(Context context, int textViewResourceId, String[] hltagList) {
super(context, textViewResourceId, hltagList);
}
and keep the line:
label.setText(hltag_List[position]);
Upvotes: 2
Reputation: 474
I think you should use ArrayList.get(int index) to obtain the i-th object in the list.
Upvotes: 0
Reputation: 24820
If it is a Arraylist , use hltag_List.get(position) .
label.setText(hltag_List.get(position));
Upvotes: 4