SimpleAdapter, Text and Image in spinner

后端 未结 4 1152
没有蜡笔的小新
没有蜡笔的小新 2020-12-28 21:59

I\'ve got a little problem. Well, let me first state what I\'m trying to accomplish. I had a spinner that pulls strings out of a stored array. Like so, you don\'t need to r

4条回答
  •  没有蜡笔的小新
    2020-12-28 22:15

    The problem is in getView you have assigned text corresponding to position using

    ((TextView) convertView.findViewById(R.id.name)) .setText((String) data.get("Name"));

    But for image u have used the same resource i.e.

    ((ImageView) convertView.findViewById(R.id.icon)) .setImageResource(R.drawable.icon);

    You need to use the "data" hashmap list and assign the image here

提交回复
热议问题