ListView implements a simple list and listview implements
Simple list of ListView implementations
:
ListView sheets that have nothing to do are as follows:
Fry. Activity01
1 package fry; 2 3 import com. example. listView. r; 4 5 import android. app. activity; 6 import android. OS. bundle; 7 import android. view. view; 8 import android. widget. adapterView; 9 import android. widget. adapterView. onItemClickListener; 10 import android. widget. arrayAdapter; 11 import android. widget. listView; 12 import android. widget. toast; 13 14 public class Activity01 extends Activity implements OnItemCl IckListener {15 private ListView listView; 16 @ Override17 protected void onCreate (Bundle savedInstanceState) {18 // TODO Auto-generated method stub19 super. onCreate (savedInstanceState); 20 setContentView (R. layout. activity01); 21 listView = (ListView) findViewById (R. id. listView); 22 ArrayAdapter <String> adapter = new ArrayAdapter <String> (this, android. r. layout. simple_expandable_list_item_1, getData (); 23 li StView. setAdapter (adapter); 24 listView. setOnItemClickListener (this); 25} 26 @ Override27 public void onItemClick (AdapterView <?> Parent, View view, int position, 28 long id) {29 // TODO Auto-generated method stub30 String string = (String) parent. getItemAtPosition (position); 31 32 Toast. makeText (this, string, Toast. LENGTH_SHORT ). show (); 33} 34 35 private String [] getData () {36 return new String [] {"Han", "Cai Jing", "Lu benwei ", "wuwukai", "Wolf 2", "Brother Chaoyang", "Hongqiao yijie", "sharp brother", "Wang baoqing", 37 "series ", "fool", "Zhang San", "Li Si", "Wang Wu" };38} 39}
/ListView/res/layout/activity01.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="vertical" > 6 7 <ListView 8 android:id="@+id/listView" 9 android:layout_width="match_parent"10 android:layout_height="wrap_content"11 ></ListView>12 13 </LinearLayout>