2010-12-30 8 views
1

私のアプリケーションでスピナーを持っています。スピナーはドロップダウンリストを持っています。私はデータベースからドロップダウンリストの値を取りたいと思います。ここここにドロップダウンリストのスピナーのコードです:

は、ドロップダウンリストで、スピナーのための私のコードです:

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, selectdefault); 
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
    spinner.setAdapter(adapter); 

答えて

0

あなたが表示したいフィールドを指定する配列を作成する必要があります。 これを試すことができます。

DatabaseProfileHelper dbhelper = new DatabaseProfileHelper(context); 
// create an array to specify which fields we want to display 
String[] from = new String[] { DatabaseProfileHelper.colNama }; 
int[] to = new int[] {R.id.txtProfileNama}; 
Cursor c = dbhelper.getAllProfiles(); 
dbhelper.UpdateProfile(null); 
c.moveToFirst(); 
startManagingCursor(c); 
// create simple cursor adapter 
SimpleCursorAdapter ca=new SimpleCursorAdapter(context,R.layout.profile_spinner_row, c, from, to); 
// get reference to our spinner 
spinProfile.setAdapter(ca);