Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何知道SimpleCorsOrAdapter中增加的值_Android_Simplecursoradapter - Fatal编程技术网

Android 如何知道SimpleCorsOrAdapter中增加的值

Android 如何知道SimpleCorsOrAdapter中增加的值,android,simplecursoradapter,Android,Simplecursoradapter,我需要知道,当添加值时,SimpleCursorAdapter有任何警报功能吗?我想要的是 我打开main活动,有列表视图与 SimpleCursorAdapter通过后台服务添加数据 当后台服务添加值时,我想刷新ListView,然后 知道增加了多少新的价值。(不希望使用通知) 就像ArrayAdapter的AddAll()和notifyDataSetChanged()一样 有可能吗?最好的方法是在数据库上设置一个内容观察者,并使用它异步加载数据。在添加新记录时请求一个新光标 引用: requ

我需要知道,当添加值时,
SimpleCursorAdapter
有任何警报功能吗?我想要的是

  • 我打开
    main活动
    ,有
    列表视图
    SimpleCursorAdapter
    通过后台服务添加数据
  • 当后台服务添加值时,我想刷新
    ListView
    ,然后 知道增加了多少新的价值。(不希望使用通知)
  • 就像
    ArrayAdapter
    AddAll()和
    notifyDataSetChanged()
    一样


    有可能吗?

    最好的方法是在数据库上设置一个内容观察者,并使用它异步加载数据。

    在添加新记录时请求一个新光标

    引用:

    requery()
    This method was deprecated in API level 11. Don't use this. Just request a new cursor, so   you can do this asynchronously and update your list view once the new cursor comes back.
    

    与所有其他适配器一样,一个简单的游标适配器也有一个notify dataset changed方法/如何知道和如何动态刷新列表?是的,游标加载程序和内容提供程序将为您管理内容,cursor.setNotificationUri(getContext().getContentResolver(),uri);通过这种方法。对于游标,我认为您必须执行重新查询。请查看android开发人员网站引用的cursor.requery是弃用的重新查询()此方法在API级别11中弃用。不要用这个。只需请求一个新的游标,就可以异步执行此操作,并在新游标返回后更新列表视图。