I have a Spinner bound to a database column by a cursor. All the examples I have found suggest the use of the SimpleCursorAdapter
which apparently is deprecated, so i have to use @SuppressWarnings("deprecation)
in order to complile correctly. I have the following code that works correctly, but I don't like having to use a deprecated feature.
private Spinner itemCategory;
itemCategory = (Spinner) findViewById(R.id.itemCategory);
private void loadCategoryOptions() {
Uri uri = Uri.parse(GoalsContentProvider.CONTENT_URI + "/categories");
String[] projection = { CategoriesTable.COLUMN_ID, CategoriesTable.COLUMN_NAME };
String selectCriteria = CategoriesTable.COLUMN_STATUS + " > 0";
String sortOrder = CategoriesTable.COLUMN_NAME + " ASC";
Cursor cursor = managedQuery(uri, projection, selectCriteria, null, sortOrder);
@SuppressWarnings("deprecation")
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_spinner_item,
cursor, new String[] { CategoriesTable.COLUMN_NAME },
new int[] {android.R.id.text1});
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
itemCategory.setAdapter(adapter);
}
I am using the Android support v4 package. Any suggestions?