Android初试--ListView的简单使用
Android中ListView组件可以说是使用频率比较高的组件之一。在Android中的几乎所有的软件中都能够看到它的影子。接下来我们就来看看ListView的简单使用。
1.准备字符串资源,在res/values/strings.xml文件中添加所需的字符串。
<string name="inputname">请输入用户名</string>
<string name="tijiao">提交</string>
<string name="inputage">请输入年龄</string>
<string name="inputsex">请输入性别</string>
2.准备输入信息的布局文件,在res/layout/activity_main.xml。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/inputname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/inputname" />
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/inputname"
/>
<TextView
android:id="@+id/inputage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/inputage"
android:layout_below="@+id/username"
/>