spinner 读取sqlite

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);   
    }   
}  
posted @ 2012-07-23 16:55  还是你最好  阅读(841)  评论(0编辑  收藏  举报