可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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.