|

- UID
- 17553
- 帖子
- 8
- 精华
- 0
- 积分
- 20
- e望
- 0 点
- e币
- 10 元
- e脉
- 0 条
- 在线时间
- 2 小时
|
3#
发表于 2010-2-9 13:54
| 只看该作者
下面就是代码~~
Activity(Test.java)- import android.app.Activity;
- import android.os.Bundle;
- import android.widget.ArrayAdapter;
- import android.widget.ListView;
- public class Test extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- ListView listView = (ListView)findViewById(R.id.list);
- listView.setAdapter(new ArrayAdapter<String>(this,
- android.R.layout.simple_list_item_1, mStrings));
- }
-
- String[] mStrings = {"aaaa", "bbbb", "cccc", "dddd", "eeee", "fff"};
- }
复制代码 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" android:background="#9AE4DD">
- <ListView android:id="@+id/list"
- android:layout_height="fill_parent"
- android:layout_width="fill_parent"></ListView>
- </LinearLayout>
复制代码 |
|