Фокус на элементе списка
Добавлено: 29 ноя 2013, 13:11
Всем привет. Столкнулся с такой проблемой: есть список, в списке поле TextView, Image и EditText. У меня не фокусируется значение на элементе списка (хочу создать контекстное меню). То есть не выделяется строка при нажатии на TextView или Iamge поле. EditText работает нормально. Что бы фокус был на элементе списка, то нужно в Layout файл добавить поле android:descendantFocusability="blocksDescendants". Но в таком случае у меня перестает работать EditText (не фокусируется на этом поле). Прилагаю код моих Layout файлов: активити со списком и элемент списка. Просьба помочь решить проблему: что бы и элемент списка можно было выделить (для создания контекстного меню) и что бы поле EditText работало. Может есть другие решения о которых я не догадываюсь? Список выводиться через адаптер. Заранее спасибо за помощь..
Activity со списком:
Элемент списка:
Activity со списком:
Код: Выделить всё
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:text="@string/button_select_folder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/button_select_folder"
android:layout_gravity="center_horizontal"
android:layout_marginTop="13dp" >
</Button>
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</ListView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:visibility="gone"
android:layout_marginTop="10dp"
android:id="@+id/tvPathToPL"
android:text="@string/tvPathToPL"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:id="@+id/btnPathToPL"
android:text="@string/btnPathToPL"
android:visibility="gone"/>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:visibility="invisible"
android:id="@+id/tlPLName">
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvPLName"
android:text="@string/tvPLName"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/etPLName"
android:inputType="textCapWords"
android:hint="@string/etPLName"/>
</TableRow>
</TableLayout>
<Button
android:text="@string/generate_playlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/generate"
android:layout_gravity="center_horizontal"
android:visibility="invisible"
android:layout_weight="0">
</Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:id="@+id/ExitApp"
android:text="@string/ExitApp"
android:layout_gravity="center_horizontal">
</Button>
</LinearLayout>Код: Выделить всё
<?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="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/LL_Option"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/OptionDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text=""
android:textSize="20sp">
</TextView>
</LinearLayout>
<EditText
android:id="@+id/OptionSongCounter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:hint="1"
android:clickable="true"
android:focusable="true"
android:textSize="20sp"
android:layout_marginTop="5dp" />
<ImageView
android:id="@+id/OptionImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher">
</ImageView>
</LinearLayout>