Привет всем, Я новичок в Android и имею проблемы с отображением элементов с использованием линейного макета и задаюсь вопросом, может ли кто-нибудь помочь мне. Список элементов и изображения отображаются отлично, но текстовое поле и кнопка поиска отображаются для каждого элемента, а не отображаются один раз. Мой код выглядит так:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"/>
<TextView
android:id="@+id/selection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/searchHeader"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/searchItem"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/search"
android:onClick="Search"/>
</LinearLayout>
</LinearLayout>
С помощью этого XML вы должны видеть только одно изображение, а не список изображений, которые вы описали. Вы программно изменяете этот макет, чтобы отображать различные изображения? Возможно, вы снова добавите элементы, которые хотите только один раз.
Попробуйте переместить текст и кнопку поиска за пределы линейных выходов, в которых они находятся.