开发者

How to save the spinner selected value to database in android?

开发者 https://www.devze.com 2023-04-11 03:16 出处:网络
I am trying to get the database values to the spinner, this works fine. Also i am saving the spinner selected value to the another database.

I am trying to get the database values to the spinner, this works fine. Also i am saving the spinner selected value to the another database. This is the code for getting data to spinner from database.

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(开发者_如何学CdocdetailsAdapter);

}

here i am trying to get the spinner value and printing.

String dosage_type = mPill_pattern.getSelectedItem().toString(); 
System.out.println("spinner:"+ mPres_doctor);

when i print the spinner selected value i am getting

10-07 09:52:20.084: INFO/System.out(5500): spinner:android.widget.Spinner@43f04420

can anybody what is the solution for this.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号