【发布时间】:2014-12-22 12:47:53
【问题描述】:
我在片段中有一个列表视图。通过单击列表视图项目,打开一个新片段以显示详细信息。在第二个详细信息片段中,我有一个编辑文本并在该编辑文本上有一个文本观察器。在编辑文本文本观察器中输入文本时,它会执行操作。在后退按钮上,我删除了详细信息片段并返回列表视图片段。 但问题是,当我第二次打开详细片段时,edittext 仍保留其先前的值。textwatcher 在新的详细片段中设置旧片段值。那么如何处理它。 请帮帮我。
public class Recieptlistfrag extends Fragment {.....
RecieptFragment fragment;
SharedPreferences preferences;
............
............
listView.setOnItemClickListener(new OnItemClickListener() {
fragment.setArguments(bundle);
getActivity().getSupportFragmentManager()
.beginTransaction().add(R.id.container_top, fragment,
"RecieptFragment").commit();
...........
现在在receitfragment的后退按钮中
getActivity().getSupportFragmentManager()
.popBackStackImmediate();
使用 textwatcher 编辑文本...
public static class MyTextWatcher implements TextWatcher
{
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
customAdapter.getFilter().filter(cs);
}
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
}
public void afterTextChanged(Editable arg0) {
}
}
【问题讨论】:
标签: android android-fragments textwatcher