在日常生活中,人们经常会使用新闻客户端、淘宝等应用程序。这些应用程序通常会有一个页面能展示多个条目信息,并且每个条目信息的布局都是一样的。Android系统提供了一个Listview控件,以解决上述问题。如果不对Listview进行数据适配,那么就无法在界面上看到布局文件中创建的Listview。
actvity_main.xml
<LinearLayout 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"
android:orientation="vertical"
tools:context=".MainActivity" >
<ListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
另外创建一个list_item.xml文件,指定Item的布局
<RelativeLayout xmlns:android="http:/