用户可在布局中定义按钮和相关控件,当用户单击时,可出现相关提示。
BaseAdapter是最基础的Adapter,也是更灵活的适配器,局限性小。
1.首先创建Android项目,并创建layout文件进行界面布局,界面布局代码如下:
layout1.xml,自定义布局页面1,添加整体ListView控件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listview1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#cbcbcb">
</ListView>
</LinearLayout>
2.layout2.xml,布局文件2,整体界面布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/icon"
android:layout_width="92dp"
android:layout_height="99dp"
android:layout_weight="0"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vert