按下后退按钮时如何清除Fragment上的ListView? [英] How to clear ListView on Fragment when back button pressed?

查看:73
本文介绍了按下后退按钮时如何清除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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆