I am using a list view as follows
String[] Shows = new String[] { \"Dexter\", \"Breaking Bad\", \"The Big Bang Theory\", \"Leverage\"};
ListView tv_show_lis
Look at this Adding 2 buttons to the text view You basically need a custom adapter for your list and need to override the getView method of it, where you can specify the item's UI layout.
For the code you've posted, instead of using an instance of ArrayAdapter, create your own adapter derived from ArrayAdapter YourData should be a class to contain reference to item's text and item's image.
Now override the getView method in your custom Adapter class. The method is used to populate the UI for an item using the position argument from
View getView(int position, View convertView, ViewGroup parent)
You can get that item using ArrayAdapter.getItem
For more details refer to the link above and http://developer.android.com/reference/android/widget/ArrayAdapter.html
Here is a tutorial for your custom Listview
Now for setting different images with respect to each item ,inside your getView() method of adapter
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.rowlayout, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.label);
ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
textView.setText(values[position]);
// Change the icon for Windows and iPhone
String s = values[position];
imageView.setImageResource(images[position]);
return rowView;
}
Where your image array will be like this
int[] images={R.drawable.green_button,R.drawable.ic_launcher,R.drawable.shape,R.drawable.splash};
Also make sure your the length of your 'images' array must be same as your items in list.
look at this example here it shows how to load the images in listview in android,you need to extends the BaseAdapter to create the custom Adapter