How to set focus on Thumb for Range Seek Bar in Accessibility Mode?
Asked Answered
S

1

9

I have a custom Range Seek Bar which has 2 custom thumbs (Max and Min) for setting the range of a seekbar. Everything's working fine as expected but as I go in accessibility mode, the focus comes in the range seekbar which is the device default behavior.

What I have tried so far :

  • Tried to get the Thumb view from the SeekBar class and forcing accessibility when the focus is supposed to come to the seekbar.
  • Used thumb.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); to force focus on the thumb of a seekbar

and also

thumb.setFocusable(true);
thumb.setFocusableInTouchMode(true);

but no positive results so far.

What I want is to focus on the Thumb instead of the Seekbar itself.

Any Suggestions will be really helpful.

Shaitan answered 11/8, 2016 at 21:5 Comment(0)
M
0
int preMin = -1;
 int preMax = -1;

final RangeSeekBar<Integer> seekBar = new RangeSeekBar<Integer>(this);
        seekBar.setRangeValues(0, 100);
//setNotifyWhileDragging is important method to achive this functionality
        seekBar.setNotifyWhileDragging(true);

        seekBar.setOnRangeSeekBarChangeListener(new RangeSeekBar.OnRangeSeekBarChangeListener<Integer>() {
            @Override
            public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer minValue, Integer maxValue) {
                int diff = maxValue - minValue;
                if (diff == 39 || diff < 40) {
                    bar.setEnabled(false);
                    if(minValue != preMin){
                        seekBar.setSelectedMinValue(preMin);
                    }
                    else if(maxValue != preMax){
                        seekBar.setSelectedMaxValue(preMax);
                    }
                    AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
                    alert.setNegativeButton(getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            seekBar.setEnabled(true);
                        }
                    });
                    alert.setCancelable(false);
                    alert.setMessage(Html.fromHtml("You cant move below 40!!")).show();

                } else {
                    preM`enter code here`in = minValue;
                    preMax = maxValue;
                }
            }
        });
Marciemarcile answered 20/8, 2016 at 12:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.