main.xml
< ?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ListView android:id="@android:id/list" android:cacheColorHint="#00000000" android:scrollbars="none" android:fadingEdge="vertical" android:soundEffectsEnabled="true" android:dividerHeight="1px" android:padding="5dip" android:smoothScrollbar="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawSelectorOnTop="false" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:layout_marginBottom="10dip" android:layout_weight="1"/> </LinearLayout>java class
public class ListView1 extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String[] phonenames = new String[] { "Android", "Windows7","Symbian", "iPhone", "Android", "Windows7", "Symbian", "iPhone", "Android", "Windows7", "Symbian", "iPhone" }; setListAdapter(new ArrayAdapter<string>(this, android.R.layout.simple_list_item_single_choice,android.R.id.text1, phonenames)); ListView list = getListView(); list.setChoiceMode(ListView.CHOICE_MODE_SINGLE); } }
Comments
Post a Comment