按下后退按钮时如何清除Fragment上的ListView? [英] How to clear ListView on Fragment when back button pressed?
本文介绍了按下后退按钮时如何清除Fragment上的ListView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
该ListView
中的所有数据均由 CursorAdapter
提供.
每当我按下后退按钮并按return
进入活动,然后单击该活动以启动我的fragment
时,所有以前的数据仍然在那里相互叠加.
All data from that ListView
is provided by a CursorAdapter
.
Whenever I pressed back button and return
to activity, then click on the activity to start my fragment
, all previous data still there stacking on top of each other.
推荐答案
在片段中创建public
方法,该方法将清除您的列表,并使用片段的实例从其父活动的On onBackPressed
调用该方法.
Make public
a method in fragment which will clear your list and call that method from its parent activity's On onBackPressed
using fragment's instance.
这篇关于按下后退按钮时如何清除Fragment上的ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文