I don't know what do you mean by "xml file for all of them" but you can get the picture by BitmapFactory.decodeResource(getResources(), R.drawable.pictureId) and show that bitmap in ImageView.
public class MySimpleArrayAdapter extends ArrayAdapter<MyImage> {
private final Context context;
private final ArrayList<MyImage> values;
public MySimpleArrayAdapter(Context context, ArrayList<MyImage> values) {
super(context, R.layout.rowlayout, values);
this.context = context;
this.values = values;
}
@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.get(i).getDesc());
imageView.setImageResource(values.get(position).getImageId());
return rowView;
}
}
public class MyImage{
String desc;
int imageId;
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/icon"
android:layout_width="22px"
android:layout_height="22px"
android:layout_marginLeft="4px"
android:layout_marginRight="10px"
android:layout_marginTop="4px" >
</ImageView>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20px" >
</TextView>
</LinearLayout>