我有一个活动,持有并显示多个片段.
当我重新输入片段时,它会自动填充所有editTexts中的文本.所有字段的文本也相同.
例:
打开片段并在两个editTexts中填写文本:
CustomEditText1:[______]
CustomEditText2:[_ acb__]
CustomEditText3:[_ qwe__]
单击后退按钮并重新输入片段
CustomEditText1:[_ qwe__]
CustomEditText2:[_ qwe__]
CustomEditText3:[_ qwe__]
这是我在片段中覆盖的方法:
public AddBookingFragment() {
// Required empty public constructor
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
tabsActivity = (TabsActivity) getActivity();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_add_booking, container, false);
lastNameEditText = (NASEditText) view.findViewById(R.id.nas_add_booking_last_name);
pnrEditText = (NASEditText) view.findViewById(R.id.nas_add_booking_pnr);
addButton = (NASButton) view.findViewById(R.id.nas_add_booking_add_button);
scanButton = (NASButton) view.findViewById(R.id.nas_add_booking_scan_button);
confirmationBox = (LinearLayout) view.findViewById(R.id.nas_add_booking_confirmation_box);
confirmationText = (NASHeaderAndSubtext) view.findViewById(R.id.nas_add_booking_confirmation_text);
confirmationBox.setVisibility(View.GONE);
bindButtons();
FontHelper.setFont(container, tabsActivity);
return view;
}
通过调试,我可以看到editText通过在覆盖的OnTextChanged内部的breakpointing来设置文本.
这是来自该断点的堆栈跟踪:
(NASEditText是我的自定义视图)
两个问题/问题:
>如何在片段恢复时阻止activity / fragment / editText填充字段中的文本?
>为什么要为所有字段填写相同的文本?