В моем фрагменте есть кнопка сброса, которая очищает некоторые EditTexts и помещает значения по умолчанию в другие. Когда это произойдет, фокус переходит к последнему EditText, которому было присвоено значение по умолчанию (а иногда и прокрутка экрана). Я бы не хотел сфокусироваться. Есть ли способ предотвратить изменение фокуса во время сброса экрана?Как остановить фокус от изменения при сбросе параметров EditTexts?
EDIT:
В соответствии с запросом здесь приведен пример моего файла макета, который демонстрирует, как организованы представления (полный файл - 700 строк). Все EditTexts вложены как эти примеры. Обратите внимание, что мои EditTexts вложены в 1 или 2 слоя в RelativeLayout в ScrollView. Поэтому для их общего родителя они являются внуками или правнуками.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<!-- So that it will scroll if in landscape mode -->
<ScrollView
android:id="@+id/scrollview_new_grade"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- my main layout frame -->
<RelativeLayout
android:id="@+id/rel_lay_new_grade"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:layout_marginTop="-4dp" >
<!-- Multiple instances like this -->
<LinearLayout
android:id="@+id/linlay_avg_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_grade_calc_prompt"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<EditText
android:id="@+id/et_grade_calc_cur_grade"
android:layout_width="95dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="0"
android:ems="10"
android:text=""
android:gravity="center_vertical|right"
android:inputType="numberDecimal"
android:maxLength="7" />
</LinearLayout>
<!-- 2 instances like this -->
<LinearLayout
android:id="@+id/linlay_weight_other_categories"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/linlay_weight_input"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:gravity="bottom"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<EditText
android:id="@+id/et_grade_calc_other_categories"
android:layout_width="95dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="right"
android:ems="10"
android:text="100"
android:gravity="center_vertical|right"
android:inputType="numberDecimal"
android:maxLength="7" />
</RelativeLayout>
</LinearLayout>
<!-- 1 radio group like this (options with EditTexts) -->
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tv_grade_calc_prompt"
android:layout_below="@id/splitline_horz6"
android:layout_marginLeft="-8dp"
android:layout_marginTop="10dp" >
<LinearLayout
android:id="@+id/linlay_radio_group_0"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- stuff -->
<EditText
android:id="@+id/et_grade_calc_target"
android:layout_width="85dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="0"
android:gravity="center_vertical|right"
android:inputType="numberDecimal"
android:maxLength="7"
android:width="70dp" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
отправьте свой файл макета. –
см. Обновление ниже –
вы можете предоставить полный 700-строчный XML-файл? Я замечаю, что XML также плохо сформирован, у вас есть открытый атрибут в RadioGroup ... –