android - AppCompatSpinner is not a view that can be bounds by this SimpleCursorAdapter -
i'm totally new android development, , i'm trying populate spinner data database column. successful in populating cursor object data, i'm doing wrong.
i read similar problems in other topics here, nothing solved issue.
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_set_grade); assetdatabasehelper dbhelper = new assetdatabasehelper(getbasecontext(), "mydb"); try { dbhelper.importifnotexist(); } catch (ioexception e) { e.printstacktrace(); } db = dbhelper.getreadabledatabase(); cursor cursor = db.rawquery("select name _id items",null); simplecursoradapter adapter = new simplecursoradapter( this, r.layout.activity_set_grade, cursor, fromcols, toviews, 0); spinner = (spinner) findviewbyid(r.id.items_spinner); adapter.setdropdownviewresource(r.id.items_spinner); spinner.setadapter(adapter); }
my activity_set_grade contains spinner (in relativelayout if matters):
<spinner android:id="@+id/items_spinner" android:layout_width="fill_parent" android:layout_height="wrap_content" />
i following error message in logcat
java.lang.illegalstateexception: android.support.v7.widget.appcompatspinner not view can bounds simplecursoradapter
thank in advance!
i believe you're importing android framework simplecursorspinner
but, because you're using library stuff, must use simplecursorspinner
library too.
that simple change on import from:
import android.widget.simplecursoradapter
to
import android.support.v4.widget.simplecursoradapter
Comments
Post a Comment