您的位置:首页 > 其它

“The constructor SimpleCursorAdapter(Context, int, Cursor, String[], int[]) is deprecated”

2015-08-07 17:03 309 查看
------Java培训、Android培训、iOS培训、.Net培训、期待与您交流! -------
package android.widget;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.view.View;

/**
* An easy adapter to map columns from a cursor to TextViews or ImageViews
* defined in an XML file. You can specify which columns you want, which
* views you want to display the columns, and the XML file that defines
* the appearance of these views.
*
* Binding occurs in two phases. First, if a
* {@link android.widget.SimpleCursorAdapter.ViewBinder} is available,
* {@link ViewBinder#setViewValue(android.view.View, android.database.Cursor, int)}
* is invoked. If the returned value is true, binding has occured. If the
* returned value is false and the view to bind is a TextView,
* {@link #setViewText(TextView, String)} is invoked. If the returned value
* is false and the view to bind is an ImageView,
* {@link #setViewImage(ImageView, String)} is invoked. If no appropriate
* binding can be found, an {@link IllegalStateException} is thrown.
*
* If this adapter is used with filtering, for instance in an
* {@link android.widget.AutoCompleteTextView}, you can use the
* {@link android.widget.SimpleCursorAdapter.CursorToStringConverter} and the
* {@link android.widget.FilterQueryProvider} interfaces
* to get control over the filtering process. You can refer to
* {@link #convertToString(android.database.Cursor)} and
* {@link #runQueryOnBackgroundThread(CharSequence)} for more information.
*/
/**
* 用于将游标列映射到XML文件中定义的文本视图或图像视图的简单适配器.
* 你可以指定有哪些列,由那些视图显示这些列的内容,并通过XML定义这些视图的呈现.
* 绑定由两个阶段组成.首先,如果SimpleCursorAdapter.ViewBinder 可用,
* 则执行 setViewValue(android.view.View, android.database.Cursor, int).
* 如果返回值为真,代表发生了绑定.如果返回值为假,并且要绑定的是文本视图,
* 则执行 setViewText(TextView, String) 方法.如果返回值为假,并且要绑定的是 ImageView,
* 则执行setViewImage(ImageView, String).如果没有适当的绑定发生, 将抛出IllegalStateException.
* 如果该适配器与过滤功能同时使用,比如在 AutoCompleteTextView中,
* 可以使用 SimpleCursorAdapter.CursorToStringConverter和 FilterQueryProvider接口,用于控制过滤过程.
* 详细信息可以参考 convertToString(android.database.Cursor)和 runQueryOnBackgroundThread(CharSequence).
*/
public class SimpleCursorAdapter extends ResourceCursorAdapter {
/**
* A list of columns containing the data to bind to the UI.
* This field should be made private, so it is hidden from the SDK.
* {@hide}
*/
protected int[] mFrom;
/**
* A list of View ids representing the views to which the data must be bound.
* This field should be made private, so it is hidden from the SDK.
* {@hide}
*/
protected int[] mTo;

private int mStringConversionColumn = -1;
private CursorToStringConverter mCursorToStringConverter;
private ViewBinder mViewBinder;

String[] mOriginalFrom;
/**
* Constructor the enables auto-requery.
*
* @deprecated This option is discouraged, as it results in Cursor queries
* being performed on the application's UI thread and thus can cause poor
* responsiveness or even Application Not Responding errors.  As an alternative,
* use {@link android.app.LoaderManager} with a {@link android.content.CursorLoader}.
*/
/**
* 构造函数,启用自动再检索功能.
*
* 该 constructor 从 API 级别 11 开始已经废弃。
* 该选项已经废止,因为他会在应用程序的 UI 线程中执行 游标的检索,
* 会导致响应变慢甚至发生应用程序无响应错误.
* 请使用带有 CursorLoader 的 LoaderManager 来代替.
* @param context    与运行中的 SimpleListItemFactory 关联的 ListView 的上下文
* @param layout    为该列表定义了视图的布局文件标识.布局文件应该至少包括“to”中定义的视图
* @param c         数据库游标.如果游标不可用,可设为空.
* @param from      代表要绑定到UI的数据的列名列表.如果游标不可用,可设为空.
* @param to        用于显示“from”参数的列的视图.应该都是 TextViews. 视图与from参数按位置一一对应.如果游标不可用,可设为空.
*/
@Deprecated
public SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
super(context, layout, c);
mTo = to;
mOriginalFrom = from;
findColumns(c, from);
}
/**
* Standard constructor.
*
* @param context The context where the ListView associated with this
*            SimpleListItemFactory is running
* @param layout resource identifier of a layout file that defines the views
*            for this list item. The layout file should include at least
*            those named views defined in "to"
* @param c The database cursor.  Can be null if the cursor is not available yet.
* @param from A list of column names representing the data to bind to the UI.  Can be null
*            if the cursor is not available yet.
* @param to The views that should display column in the "from" parameter.
*            These should all be TextViews. The first N views in this list
*            are given the values of the first N columns in the from
*            parameter.  Can be null if the cursor is not available yet.
* @param flags Flags used to determine the behavior of the adapter,
* as per {@link CursorAdapter#CursorAdapter(Context, Cursor, int)}.
*/
/**
* 标准构造函数
*
* @param context   与运行中的 SimpleListItemFactory 关联的 ListView 的上下文
* @param layout    为该列表定义了视图的布局文件标识.布局文件应该至少包括“to”中定义的视图
* @param c         数据库游标.如果游标不可用,可设为空.
* @param from      代表要绑定到UI的数据的列名列表.如果游标不可用,可设为空.
* @param to        用于显示“from”参数的列的视图.应该都是 TextViews. 视图与from参数按位置一一对应.如果游标不可用,可设为空.
* @param flags     用于决定适配器行为的标志位.与 CursorAdapter(Context, Cursor, int) 相同.
*/
public SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from,
int[] to, int flags) {
super(context, layout, c, flags);
mTo = to;
mOriginalFrom = from;
findColumns(c, from);
}

......

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: