android disable seek bar for audio controller

假装没事ソ 提交于 2019-12-04 09:14:25

问题


I used the following seek bar for displacing the progress of my audio.

<SeekBar
    android:padding="7dp"
    android:id="@+id/SeekBar01"
    android:layout_width="245dip"
    android:thumb="@drawable/seekthumb2"
    android:progressDrawable="@drawable/seekbar1"
    android:layout_height="fill_parent"
    android:clickable="false"
    android:focusable="false"

    android:longClickable="false"/>

I want to disable the manual motion of this seek bar. i mean the seek can only move by my code and it cannot be accessed by any other means (Touch).


回答1:


Just add touch event handler and return true, like example below:

    seekBar.setOnTouchListener(new OnTouchListener(){
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

User won't be able to touch and change the progress this way.




回答2:


Try adding a empty eventhandler for the event of "click".




回答3:


Try this

seekBar.setEnabled(false);


来源:https://stackoverflow.com/questions/4020881/android-disable-seek-bar-for-audio-controller

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!