SimpleCursorAdapter's old constructor deprecated.. really?

后端 未结 5 1687
春和景丽
春和景丽 2021-02-06 02:20

Here it says that SimpleCursorAdapter\'s API level 1 constructor is deprecated and the use of LoaderManager and CursorLoader is recommende

5条回答
  •  鱼传尺愫
    2021-02-06 03:09

    Just use the constructor below it, the one that takes the flags. Don't use the FLAG_AUTO_REQUERY, just pass 0 for the flags.

    Unless you really need to handle data changes to the underlying DB while the user is looking at the ListView then you don't need to worry about needing to requery.

    If on the other hand you want the ListView to show changes to the DB while the user is looking at the list then follow Google's advice and use the CursorLoader.

    EDIT:

    Since the second constructor is only available in API 11 you may just want to extend CursorAdapter yourself. You pretty much just need to implement bindView and newView and you are done.

提交回复
热议问题