1

我正在通过呼叫者获取自定义铃声 ID,基本上我想做一个 setSelection(); 用那个铃声给我的微调器,但我不知道如何匹配位置..

我尝试的是匹配一个字符串“铃声名称”以从它的光标中找到它在 Spinner 中的位置。我会以正确的方式去做吗?或者有没有更简单的方法来匹配铃声 ie: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;
        }
4

0 回答 0