置换SimpleCursorAdapter? [英] Replacement for SimpleCursorAdapter?

查看:105
本文介绍了置换SimpleCursorAdapter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待在记事本教程在Android开发者网站,并注意到 SimpleCursorAdaptor 是pcated德$ P $。

I'm looking at the Notepad Tutorial on the Android developer's site and noticed that SimpleCursorAdaptor is deprecated.

新构造

public SimpleCursorAdapter (Context context, int layout, 
    Cursor c, String[] from, int[] to, int flags)

仅在API 11可

is only available in API 11.

建议的替代方案是使用 LoadManager CursorLoader ,但这些还需要API 11.那么,什么可以替换 SimpleCursorAdapter 在10 API,即应该如何本教程的步骤12 进行使用非德precated方法?

The suggested alternative is to use LoadManager with a CursorLoader, but these also require API 11. So what can replace SimpleCursorAdapter in API 10, i.e. how should Step 12 of the tutorial be done using a non-deprecated method?

推荐答案

请注意,德precation做的不可以适用于所有的 SimpleCursorAdapter ,只是一个

Please note that the deprecation does not apply to all ofSimpleCursorAdapter, just one of the constructors.

如果你想使用Loader从11 API,你可以在兼容性库拉(参见:<一href="http://developer.android.com/sdk/compatibility-library.html">http://developer.android.com/sdk/compatibility-library.html).这提供了一个补丁包,它与API级别4或更高版本的设备兼容。

If you wish to use the Loader from API 11, you can pull in the compatibility library (see: http://developer.android.com/sdk/compatibility-library.html). This provides a backport that is compatible with API level 4 or higher devices.

编辑:

如果你还在使用兼容性库后面临的错误,那么你只需要更换

If you are still facing the errors after using compatibility library, then you just need to replace

import android.widget.SimpleCursorAdapter;

import android.support.v4.widget.SimpleCursorAdapter;

这篇关于置换SimpleCursorAdapter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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