在机器人应用程序,我从装载数据的分贝到片段中的表格视图。但是,当我的重新加载在片段它显示了previous数据。我可以重新填充的片段与当前的数据,而不是previous数据?
In an android application I'm loading data from a db into a table view inside a fragment. But when I reload the fragment it displays the previous data. Can I repopulate the fragment with current data instead of previous data?
我想你想为刷新片段在DB更新内容
如果是这样,分离的片段,再重新装
If so, detach the fragment and reattach it
// Reload current fragment
Fragment frg = null;
frg = getSupportFragmentManager().findFragmentByTag("Your_Fragment_TAG");
final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.detach(frg);
ft.attach(frg);
ft.commit();
Your_Fragment_TAG是你给你的片段,当你创建它的名字
Your_Fragment_TAG is the name you gave your fragment when you created it
这code是支持库。
如果你不支持较旧的设备,只需使用 getFragmentManager 而不是 getSupportFragmentManager
If you're not supporting older devices, just use getFragmentManager instead of getSupportFragmentManager
上一篇:移动互联网 - 禁用长触摸/ taphold文本选择互联网、文本、taphold
下一篇:有没有Objective-C和Java或iPhone和Android之间的巨大差异?差异、巨大、Java、Objective