Android 铃声选择器微调器

发布于 2024-12-21 17:46:41 字数 1673 浏览 3 评论 0原文

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

I'm trying to make a spinner from Ringtone manager and it's giving me some funny results. THe spinner is coming up fine pulling the ringtone results... but each ringtone result has a radio button...? And when I select a ringtone and run the onItemSelected... it give me nothing and doesn't toast... Any thoughts?

    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();
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文