How can I make a list with pictures and summary (the text under the item list text) it is little description to item.
My code makes a list with pictures. How can I add a Summary?
<?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"
android:src="@drawable/ic_launcher" >
</ImageView>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:textSize="20px" >
</TextView>
</LinearLayout>
Activity class:
public class MyListActivity extends ListActivity {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
"Linux", "OS/2" };
// Use your own layout
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.rowlayout, R.id.label, values);
setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
String item = (String) getListAdapter().getItem(position);
Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
}
}
You can create a costum listview with a costum layout.
In the internet you found a lot of good tutorials to teach you that.
Here is an example:
http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/
The only difference to your case is that the image is on the left of the text and you want it on the top :).
If your list has always the same content you can create an adapter that already knows that content. Otherwise, you need to create a class to hold the type of content you will have on your list. It seems your content is static, so, I will suggest some lines for you to follow.
Mainly you have to create your adapter: