我有一個ListView
,我使用適配器陣列填充它。我想在那裏添加一個搜索欄,但是當我添加一個搜索欄時,它會重複它,所以我最終創建了兩個佈局文件:一個用於搜索欄,另一個用於項目列表。在項目列表佈局上放置搜索欄
的ListView在我的Android:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:paddingRight="16dp">
<ImageView
android:id="@+id/icon"
android:layout_width="40dp"
android:layout_height="70dp"
android:background="@color/bckground"
android:src="@drawable/placeholder" /> <!-- ree image-->
<LinearLayout
android:id="@+id/textContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/icon"
android:orientation="vertical"
android:paddingTop="16dp">
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
tools:text="name" />
<TextView
android:id="@+id/surname"
android:layout_width="match_parent"
tools:text="surname" />
</LinearLayout>
ListView控件佈局打印屏幕:
搜索欄文件格式:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/searchtext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text"
android:text="Search.." />
<Button
android:id="@+id/sumbit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Search" />
</LinearLayout>
搜索欄佈局打印屏幕:
我想有一個佈局的搜索欄和項目清單。 如何將這兩個佈局文件組合在一起?