1
public class MainActivity extends AppCompatActivity {
Cursor c;
Button b1;
EditText e1,e2,e3;
Spinner s1,s2;
SQLiteDatabase db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Open_Helper helper=new Open_Helper(getApplicationContext());
db=helper.getWritableDatabase();
c=db.rawQuery("select mid as _id,* from menu",null);
s1= (Spinner) findViewById(R.id.spinner3);
SimpleCursorAdapter sr=new SimpleCursorAdapter(getApplicationContext(),R.layout.activity_main,c,new String[]{"_id","mname"},new int[]{R.id.spinner3,R.id.spinner4},0);
sr.setDropDownViewResource(R.id.spinner3);
s1.setAdapter(sr);
}
}
錯誤是微調值給出錯誤
java.lang.IllegalStateException: android.widget.Spinner is not a view
that can be bounds by this SimpleCursorAdapter
你看了(HTTP [使用SimpleCursorAdapter有微調?]://計算器。 com/a/26515766/4391450) – AxelH