Серьезно, никто не знает, как этого достичь. Возможно ли это ?. Может быть, ответ «да» или «нет» может помочь мне!Клавиша клавиатуры табулятора в формуляре
У меня есть форма, которая выглядит следующим образом:
прямоугольники с B на нем, означает, что есть кнопки. Другие поля - «Редактировать тексты и текстовые представления».
Я хочу, чтобы иметь возможность нажать на клавиатуре Tabulator и фокус в этом направлении:
- первое имя Редактирование текста
- второй компании Редактировать текст
- третья кнопка
- четвёртую Сотрудник Редактирование текста
- 5-я кнопка
- 6-я Дата
- 7-я кнопка
- восьмого Время
- девятая Кнопка
- десятого Описания Редактировать текст
- 11 Отметить как сделать флажок
- 12 сохранить
- 13 чистых
Это мой макет:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/ContenedorPrincipal"
tools:context=".ClientsActivity" >
<TextView
android:id="@+id/textViewTask"
style="@style/FTitle"
android:text="@string/new_task" />
<!--____________________ Section: form, field: name task______________________________-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3dp"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewTaskName"
style="@style/FForm"
android:text="@string/name" />
<EditText
android:id="@+id/editTextTaskName"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textCapSentences" >
</EditText>
</LinearLayout>
<!--______________________________ Section: form, fields: company,employee____________________-->
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="3dip"
android:stretchColumns="1,4" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textViewCompany"
style="@style/FForm"
android:text="@string/company" />
<AutoCompleteTextView
android:id="@+id/autocompleteCompany" />
<ImageButton
android:id="@+id/imageButtonWatchCompany"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_view"
android:contentDescription="@string/see_company"/>
<TextView
android:id="@+id/textViewEmployee"
style="@style/FForm"
android:text="@string/employee" />
<AutoCompleteTextView
android:id="@+id/autocompleteEmployee" />
<ImageButton
android:id="@+id/imageButtonWatchEmployee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_view"
android:contentDescription="@string/see_employee"/>
</TableRow>
<!--____________________ Section: form, fields: date, time______________________________-->
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textViewDate"
style="@style/FForm"
android:text="@string/date" />
<Button
android:id="@+id/buttonDate" >
</Button>
<TextView />
<TextView
android:id="@+id/textViewTime"
style="@style/FForm"
android:text="@string/time" />
<Button
android:id="@+id/buttonTime">
</Button>
</TableRow>
</TableLayout>
<!--____________________ Section: form, field description ______________________________-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewDescription"
style="@style/FForm"
android:text="@string/description" />
<EditText
android:id="@+id/editTextDescription"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:lines="5"
android:gravity="top|left"
android:scrollbars="vertical"
android:inputType="textMultiLine|textCapSentences"/>
</LinearLayout>
<CheckBox
android:id="@+id/checkBoxDone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/mark_as_done"/>
<!--____________________ Section: buttons: save and clean______________________________-->
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="3dip"
android:stretchColumns="0,1">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="UselessParent" >
<Button
android:id="@+id/buttonSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/save" />
<Button
android:id="@+id/buttonClean"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/clean" />
</TableRow>
</TableLayout>
Есть ли в любом случае, чтобы достичь этого ?. Любая помощь будет одобрена.
РЕШЕНИЕ
В макете обязательно используйте андроид: imeOptions = "actionNext":
<AutoCompleteTextView
android:id="@+id/autocompleteCompany"
android:imeOptions="actionNext" />
И программно в методе onCreateView, вызовите к персональному методу:
private void setUpFocus(View view){
etName.setNextFocusDownId(R.id.autocompleteCompany);
etCompany.setNextFocusDownId(R.id.imageButtonWatchCompany);
ImageButton button = (ImageButton) view.findViewById(R.id.imageButtonWatchCompany);
button.setFocusableInTouchMode(true);
}
С помощью этой части кода, используя ключ табуляции, я могу перейти от имени, затем к компании, затем к первой кнопке, затем использовать е.
В конце концов, кто-то отвечает. Благодарю. Я сделал то, что вы упомянули, но он не работает для кнопок. На самом деле я получаю предупреждение в затмении, в котором говорится: «Предназначено для редактируемых текстовых виджетов». И текст редактирования сотрудника никогда не фокусируется, потому что фокус идет вверх вниз, а не слева направо. Любая другая подсказка ?. – kiduxa
А, ладно, я не понимал, что его нельзя использовать на кнопках. Как насчет 'android: nextFocusDown'или' android: nextFocusRight'? Я не использовал их раньше, но документация указывает, что они могут быть полезны для переключения фокуса в нужном направлении, когда пользователь нажимает вкладку или следующий. – mattgmg1990
Хорошо, используя андроид: nextFocusRight and android: imeOptions = "actionNext" У меня есть часть желаемого фокуса. Я имею в виду, я могу пойти от компании к сотруднику, но я не могу сфокусировать свою кнопку. Im пытается это: etCompany.setNextFocusRightId (R.id.imageButton1); и в моем макете: –
kiduxa