我正在通过来电者获得自定义铃声ID,基本上我想做一个setSelection();用那个铃声给我的微调器,但我无法弄清楚如何匹配位置..
我尝试过的是匹配一个字符串“Ringtone Name”,从它的光标中找到它在Spinner中的位置。我是以正确的方式去做的吗?或者是否有更简单的方法来匹配铃声即:content:// media / internal / audio / media / 72到微调器中的位置?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
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
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}; //sets the items from above string to listview
// 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_item);
// get reference to our spinner
s = (Spinner) findViewById( R.id.spinner1);
s.setAdapter(adapter);
getValue(mCursor2);
s.setSelection(posid);
s.setOnItemSelectedListener(this);
}
public String getValue(Cursor cursor) {
String posid = "Loopy Lounge";
while (cursor.moveToNext()) {
posid = cursor.getString(0);
}
return;
}