0

I need to play the audio inside RecyclerView . Requirement is SeekBar will be enable after user clicked the play button . So i tried.

<SeekBar
                android:id="@+id/seek_Media_Player"
                android:layout_width="match_parent"
                android:layout_marginLeft="@dimen/_6sdp"
                android:clickable="false"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:layout_marginRight="@dimen/_6sdp"
                android:layout_height="wrap_content" />

But its not working . android:clickable="false" worked when i use SeekBar inside an Activity or Fragment but not inside RecyclerView. I also tried to set those attribute at runtime but not worked.

Setting setEnabled(false) making SeekBar invisible. I have been busting my head on this from last 6 hours. I am posting the item image just to show . Please let me know how can i disable/enable click on SeekBar.

enter image description here

Diaz diaz
  • 284
  • 1
  • 7
  • 21
  • https://stackoverflow.com/questions/16284219/disable-changes-on-seekbar-by-client – AskNilesh Jun 19 '18 at 11:58
  • this is a hack you can set touch listener and return true I nside onTouch method.. there will. e better solution than this. – pop Jun 19 '18 at 12:22

1 Answers1

0

Ok so i found the solution . It was suspected previously but i was looking for some other way to do it . I thought problem was somewhere in my code . but it was't. Below is the complete solution i have used.

public class CustomSeekBar extends AppCompatSeekBar {
private boolean fuzzyEnable;

public void setFuzzyEnable(boolean fuzzyEnable) {
    this.fuzzyEnable = fuzzyEnable;
}
public CustomSeekBar(Context context) {
    super(context);
}

public CustomSeekBar(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public CustomSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    return fuzzyEnable?super.onTouchEvent(event):true;
}

}
Diaz diaz
  • 284
  • 1
  • 7
  • 21