Focus on technology, enjoy life! --qq:804212028
Browse Links: http://blog.csdn.net/y18334702058/article/details/44624305
- Topic: ListView of the User interface (list view)
-listview and Textview,button are the same way of defining and displaying, so they are no longer repeated. But the ListView in Android development often fits some adapters to display, so we have to learn to focus on the various adaptations of the ListView.
Arrayadapter adaptation display for ListView
<?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" > <ListViewandroid:id="@+id/listview"android:layout_width= "Fill_parent" android:layout_height="wrap_content" /> </linearlayout>
Mainactivity.java Source code:
Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.widget.ArrayAdapter;ImportAndroid.widget.ListView; Public class mainactivity extends Activity { PrivateListView ListView; String[] str={"AA","BB","CC","DD","ee"};@Override protected void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate); Setcontentview (R.layout.activity_main); ListView = (ListView) Findviewbyid (R.id.listview); arrayadapter<string> adapter =NewArrayadapter<string> ( ThisAndroid. R.layout.simple_list_item_1, str); Listview.setadapter (adapter); }}
Operation Result:
It's a little late today. Tomorrow I will continue to update, but also a lot of knowledge points.
Step by step series of courses, will continue to edit repeatedly, remove some previously not written good, add new good things. So this series of blog posts will always be getting better and more comprehensive. If you have any support, please pay attention to this series.
Focus on technology, enjoy life! --qq:804212028
Browse Links: http://blog.csdn.net/y18334702058/article/details/44624305
Step by Step _android Development Course [19]_ User Interface ListView (List view)