Ringtone manager からスピナーを作成しようとしていますが、面白い結果が得られます。スピナーは着メロの結果を引っ張ってうまくいきます...しかし、各着メロの結果にはラジオボタンがあります...? そして、着信音を選択して onItemSelected を実行すると... 何も表示されず、乾杯もしません... 何か考えはありますか?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mRingtoneManager2 = new RingtoneManager(this); //adds ringtonemanager
mRingtoneManager2.setType(RingtoneManager.TYPE_RINGTONE); //sets the type to ringtones
mRingtoneManager2.setIncludeDrm(true); //get list of ringtones to include DRM
mCursor2 = mRingtoneManager2.getCursor(); //appends my cursor to the ringtonemanager
startManagingCursor(mCursor2); //starts the cursor query
//prints output for diagnostics
String test = mCursor2.getString(mCursor2.getColumnIndexOrThrow(RingtoneManager.EXTRA_RINGTONE_TITLE));
Log.d(null, test, null);
String[] from = {mCursor2.getColumnName(RingtoneManager.TITLE_COLUMN_INDEX)}; // get the list items for the listadapter could be TITLE or URI
int[] to = {android.R.id.text1};
// create simple cursor adapter
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, mCursor2, from, to );
adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
// get reference to our spinner
s = (Spinner) findViewById( R.id.spinner1);
s.setAdapter(adapter);
}
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
int pos = s.getSelectedItemPosition();
Toast.makeText(this, pos, Toast.LENGTH_SHORT).show();
}