Unclickable Seekbar in android listview

匿名 (未验证) 提交于 2019-12-03 02:30:02

问题:

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"         android:longClickable="false" 

回答1:

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


回答2:

Add focusable=false to the seekbar.



回答3:

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.



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