android 如何从sqlite读取数据到spinner下拉中显示

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.Data;
import android.widget.SimpleCursorAdapter;
import android.widget.Spinner;

public class temp extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Cursor c = managedQuery(Data.CONTENT_URI,
           new String[]{ Data._ID, Data.DATA1 },
           Data.MIMETYPE + "='" + StructuredName.CONTENT_ITEM_TYPE + "'",
           null,
           null);

        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
               android.R.layout.simple_dropdown_item_1line,
               c,
               new String[]{ Data.DATA1 },
               new int[]{ android.R.id.text1 });
       
        Spinner s1 = (Spinner) findViewById(R.id.Spinner01);
        s1.setAdapter(adapter);
    }
}

你可能感兴趣的:(C++,c,android,sqlite,OS)