0

我不确定我做错了什么,但这个问题正在吞噬我的头脑。在下面的代码中,R.layout.rowR.id.value都显示为错误,并在Eclipse上显示为红线。它确实说SimpleCursorAdapter 已被弃用,但使用@SuppressWarnings("deprecation"),它应该可以工作,对吧?

@SuppressWarnings("deprecation")
    @Override
    protected void onPostExecute(Void result)
    {
        // TODO Auto-generated method stub
        super.onPostExecute(result);
        SimpleCursorAdapter adapter;
        if(Build.VERSION.SDK_INT>= Build.VERSION_CODES.HONEYCOMB)
        {
            adapter=new SimpleCursorAdapter(getActivity(), R.layout.row, constantCursor, new String[] { DatabaseHelper.TITLE, DatabaseHelper.VALUE }, new int[] { R.id.title, R.id.value }); 

        }
        else
        {
            adapter=new SimpleCursorAdapter(getActivity(), R.layout.row, constantCursor, new String[] { DatabaseHelper.TITLE ,DatabaseHelper.VALUE }, new int [] { R.id.title, R.id.value }); 
        }

        setListAdapter(adapter); 
    }

res/layout目录下的row.xml以下内容:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView 
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:textSize="20sp"
    android:textStyle="bold"
    />

<TextView 
    android:id="@+id/value"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:textSize="20sp"
    android:textStyle="bold"
    />

</RelativeLayout>
4

0 回答 0