我正在尝试将数据库值提供给微调器,这很好。此外,我将微调器选定的值保存到另一个数据库。 这是从数据库获取数据到微调器的代码。
private void filldata()
{
Cursor docdetailsCursor;
Spinner docdetailsSpinner = (Spinner) findViewById(R.id.doctornamespinner);
docdetailsCursor = mDbHelper1.fetchAlldetails();
startManagingCursor( docdetailsCursor);
/*Create an array to specify the fields we want to display in the list (only the 'colourName' column in this case) */
String[] from = new String[]{DoctorDb.KEY_NAME};
/* and an array of the fields we want to bind those fields to (in this case just the textView 'tvDBViewRow' from our new db_view_row.xml layout above) */
int[] to = new int[]{R.id.text1};
SimpleCursorAdapter docdetailsAdapter =
new SimpleCursorAdapter(this, R.layout.spinner_row, docdetailsCursor, from, to);
/* and assign it to our Spinner widget */
docdetailsSpinner.setAdapter(docdetailsAdapter);
}
这里我试图获得微调器值并打印。
String dosage_type = mPill_pattern.getSelectedItem().toString();
System.out.println("spinner:"+ mPres_doctor);
当我打印微调器选定值时,我正在
10-07 09:52:20.084: INFO/System.out(5500): spinner:android.widget.Spinner@43f04420
任何人都能解决这个问题。