本篇文章通过一个例子实现ListView列表视图并且点击不同的项进入不同的界面
第一步,我们需要在布局文件中设置ListView属性
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<ListView
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
那么在ListView里面需要什么内容呢
第二步,添加界面
1.在string里面设置文字,其实在xml文件或者activity界面里面我们也可以直接写文字,但是如果将文字都写在string里面,统一管理文字,这对以后我们修改起来会方便很多
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">ListViewDemo</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="demo1_name">测试1</string>
<string name="demo1_title">测试1名称</string>
<string name="demo1_desc">测试1描述:这是一个测试例子</string>
<string name="demo2_name">测试2</string>
<string name="demo2_title">测试2