我正在使用目标API 16和最低API 11以及编译器1.7的合规级别 当我在LoaderCallbacks的方法上使用@Override表示法时,例如OnLoadFinished,OnCreateLoader,检查结果表明我必须覆盖超类方法。
Eclipse SDK
版本:4.2.1 构建ID:M20120914-1800
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.birthdays"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="15" />
<application android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
</application>
</manifest>
public class MainActivity extends ListActivity implements LoaderManager.LoaderCallbacks<Cursor>
{
private static final int ACTIVITY_CREATE = 0;
private static final int DELETE_ID = Menu.FIRST + 1;
private AppSqliteDataBase dataSource;
private Cursor cursor;
private SimpleCursorAdapter adapter;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// this.getListView().setDividerHeight(2);
dataSource = new AppSqliteDataBase(this);
dataSource.open();
cursor = dataSource.getCursor();
fillData();
registerForContextMenu(getListView());
}
private void fillData()
{
String[] from = new String[] { dataSource.getCredentialsColName() };
int[] to = new int[] { R.id.list_label };
adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, cursor, from, to, 0);
setListAdapter(adapter);
getLoaderManager().initLoader(0, null, this);
}
public Loader<Cursor> onCreateLoader(int id, Bundle args)
{
// String[] projection = { dataSource.getIdColName(), dataSource.getCredentialsColName() };
SQLiteCursorLoader cursorLoader = new SQLiteCursorLoader(this,
dataSource.dbHelper, "select _id, credentials from birthdays where 1", new String[]{});
return cursorLoader;
}
public void onLoaderReset(Loader<Cursor> loader)
{
adapter.swapCursor(null);
}
public void onLoadFinished(Loader<Cursor> loader, Cursor data)
{
adapter.swapCursor(data);
}
}
答案 0 :(得分:0)
将编译器合规性级别更改为1.6, 在eclipse中右键单击您的项目转到属性并选择编译器选项