开发者

Unclickable Seekbar in android listview

I have a Listview in my application. Listview rows are clickable. I have introduced a seek bar in each row of a Listview. Despite settings android:clickable="false" for Seekbar in layout xml, I am still able to click on it and move seek bar as desired. I don't want Seekbar to be clickbale but I do want Listview row to clickable.

Any pointers will be appreciated.

Here's my layout file

android:progressDrawable="@drawable/slider_range"
        android:thumb="@drawable/slider_thumb"
        android:layout_width="80dip"
        android:layout_height="12dip"
        android:focusable="false"
        android:clickable="false"
        开发者_如何学JAVAandroid:longClickable="false"


seekBarObj.setOnSeekBarChangeListener( new OnSeekBarChangeListener() {

        int originalProgress;

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            //Nothing here..                
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

            originalProgress = seekBar.getProgress();
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int arg1, boolean fromUser) {
            if( fromUser == true){
                seekBar.setProgress( originalProgress);
            }               
        }
    });


Try setting the enabled attribute to false. You may have to manually adjust the color if you want to avoid it appearing "greyed out"

e.g.

seekBar.setEnabled(false);

I've now got this working using both setFocusable and setEnabled to false, I've implemented a solution to enable the seekbar for a single adjustment when the list item is clicked too if you are interested.


Add focusable=false to the seekbar.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜