Simpleadapter: Wraps more than one object from the list collection into a listing item.
We can use Simpleadapter to implement some complex lists, see the following examples:
Simpleadapter_list Layout file:
<span style= "FONT-SIZE:18PX;" ><?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/ Res/android " android:layout_width=" match_parent " android:layout_height=" match_parent " android:o rientation= "vertical" > <listview android:id= "@+id/lv_simpleadapter" android:layout_width= " Fill_parent " android:layout_height=" wrap_content "> </listview></linearlayout></span >
Simpleadapter layout file: The component used to display list items
<span style= "FONT-SIZE:18PX;" ><?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/ Res/android "android:layout_width=" match_parent "android:layout_height=" match_parent "> <LinearLayout Android:id= "@+id/ll_top" android:layout_height= "wrap_content" android:layout_width= "Fill_parent" a ndroid:orientation= "Horizontal" > <imageview android:id= "@+id/iv_image" android:layout_height= "wrap _content "android:layout_width=" wrap_content "android:scaletype=" Fitxy "android:src=" @drawable/a5i " android:layout_gravity= "center"/> <linearlayout android:id= "@+id/ll_right" Android:layout_wi Dth= "Fill_parent" android:layout_height= "wrap_content" android:orientation= "vertical" android:layout_ margintop= "4DP" > <textview android:id= "@+id/tv_title" android:layout_height= "Wrap_cont ENT "android:layout_width=" Wrap_content "android:textsize=" 20SP "android:text=" as "/> <textview android:id= "@+id/tv_des" android:layout_height= "Wrap_content" Android : layout_width= "wrap_content" android:textsize= "13SP" android:text= "as"/> </line Arlayout></linearlayout></relativelayout></span>
Simpleadaptertest Main file:
<span style= "FONT-SIZE:18PX;" >public class Simpleadaptertest extends Activity {int[] images = new int[] {r.drawable.a5i, r.drawable.a5j, r.drawable . a5k}; String[] titles = new string[] {"Phone", "QQ", "Contact"}; string[] des = new string[] {"Currently no phone record", "currently no QQ chat record", "Recently no Contact"};p rivate ListView lv_simple; @Overrideprotected void Oncrea Te (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.simpleadapter_list); Initview (); SetData ();} private void Initview () {lv_simple = (ListView) Findviewbyid (r.id.lv_simpleadapter); Lv_simple.setonitemclicklistener (New Onitemclicklistener () {@Overridepublic void Onitemclick (adapterview<?> parent, View view,int position, long ID) {Toast.maketext (Simpleadaptertest.this, Titles[position],toast.length_short). Show ();}}); private void SetData () {//Create data source list
Reprint Please specify the Source: http://blog.csdn.net/hai_qing_xu_kong/article/details/42361041 Emotional Control _
Learn about Android Simpleadapter use (13)