Android片段中的EditText值不会刷新

Android片段中的EditText值不会刷新,第1张

概述我正在使用Viewpager在3个片段之间切换,一切正常,除了刷新第二个标签(或片段).在此选项卡中,我有一张图片,一些静态Textviews,一些动态TextView和一些EditText字段. 每次选择第二个选项卡时,都会在所有动态字段上调用setText(). TextView组件和微调器正在刷新并更新其内容,但EditText元素则不会. 我不明白为什么这些字段没有更新.更换标签后,我在T 我正在使用VIEwpager在3个片段之间切换,一切正常,除了刷新第二个标签(或片段).在此选项卡中,我有一张图片,一些静态TextvIEws,一些动态TextVIEw和一些EditText字段.

每次选择第二个选项卡时,都会在所有动态字段上调用setText(). TextVIEw组件和微调器正在刷新并更新其内容,但EditText元素则不会.
我不明白为什么这些字段没有更新.更换标签后,我在TabsAdapter中调用notifiyDataSetChanged().每次我更改选项卡时都会调用onVIEwCreated().在第二个片段的onVIEwCreated()中,我正在更改元素的内容.

那是我片段的代码:

@OverrIDepublic VIEw onCreateVIEw(LayoutInflater inflater,VIEwGroup container,Bundle savedInstanceState) {    hA = (HelloAndroIDActivity)this.getSherlockActivity();    appState = ((TestApplication)this.getSherlockActivity().getApplicationContext());    final PersistenceHelper pH = new PersistenceHelper(appState);    m = pH.readMitarbeiter(todisplay);     // Inflate the layout for this fragment    v = inflater.inflate(R.layout.detailfragment,container,false);    if(m==null) {                   //If Mitarbeiter is empty        pH.closeDB();        return v;    }    //Inflating Elements    employeename = (TextVIEw)v.findVIEwByID(R.ID.employee_name);    cdate = (TextVIEw)v.findVIEwByID(R.ID.department);    currentPlace = (TextVIEw)v.findVIEwByID(R.ID.place_label);    comment_text = (EditText)v.findVIEwByID(R.ID.comment_text);    reachable = (EditText)v.findVIEwByID(R.ID.reachable_text);    state = (Spinner)v.findVIEwByID(R.ID.spinner_state);    durchwahl = (EditText)v.findVIEwByID(R.ID.durchwahl);    department = (EditText)v.findVIEwByID(R.ID.department_edit);    email = (EditText)v.findVIEwByID(R.ID.email_edit);    img = (ImageVIEw)v.findVIEwByID(R.ID.userPic);    changeData = (button)v.findVIEwByID(R.ID.changebutton);    //Setting Elements    employeename.setText(m.getL_name());    currentPlace.setText(m.getStatus());        comment_text.setText(m.getBemerkung());    reachable.setText(m.getErreichbar());           email.setText(m.getS_name()+"");            durchwahl.setText(m.getDurchwahl()+"",TextVIEw.BufferType.EDItable);    department.setText(m.getFunktion(),TextVIEw.BufferType.norMAL);    //Spinner    String[] values = { "Anwesend","MitTagspause","Ausser Haus","DIEnstreise","Krankenstand","Zeitausgleich","Urlaub","Abwesend" };    ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this.getSherlockActivity(),androID.R.layout.simple_spinner_item,values);    state.setAdapter(spinnerArrayAdapter);    state.setSelection(StateMapper.returnState(m.getStatus()));    //Image    //.......    return v;}

正如我之前提到的,我的Image,TextVIEw和Spinner Elements正在刷新它们的内容.我还检查了所有变量的内容,除了这些EditText元素外,一切似乎都很好.如果我将EditText元素转换为TextVIEw,则内容正在改变(在代码中但不在GUI中).让我绝望的是,EditText在我第一次设置值时刷新.

有谁有想法,我怎么能刷新我的EditText字段的内容?

解决方法 我不确定但是尝试onResume()并将文本设置为恢复状态.

或尝试

选项卡更改上的Intent.FLAG_ACTIVITY_CLEAR_top.

总结

以上是内存溢出为你收集整理的Android片段中的EditText值不会刷新全部内容,希望文章能够帮你解决Android片段中的EditText值不会刷新所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1131206.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存