何が間違っていたのかわかりませんが、この問題は私の頭を悩ませています。以下のコードでは、R.layout.rowとR.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>