0

我正在使用目标 API 16 和最低 API 11 与编译器 1.7 的合规级别当我在 LoaderCallbacks 的方法(例如 OnLoadFinished、OnCreateLoader)上使用 @Override 表示法时,检查结果显示我必须覆盖超类方法的错误。

Eclipse SDK

版本:4.2.1 版本号: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);
        }
    }
4

1 回答 1

0

将您的编译器合规级别更改为 1.6,在 Eclipse 中右键单击您的项目转到属性并选择编译器选项

于 2012-10-29T09:48:23.600 回答