在Eclipse中未检测到布局的XML文件

时间:2013-08-01 09:17:03

标签: android xml eclipse deprecated

我不确定我做错了什么,但这个问题正在吃我的脑袋。在下面的代码中, R.layout.row R.id.value 都会在上显示为红线的错误Eclipse 。它确实说 SimpleCursorAdapter已被弃用但是使用 @SuppressWarnings(“弃用”),它应该可以正常工作,对吗?

@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>

0 个答案:

没有答案