我正在尝试从铃声管理器制作一个微调器,它给了我一些有趣的结果。微调器正在拉动铃声结果......但是每个铃声结果都有一个单选按钮......?当我选择一个铃声并运行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();
}