Android - Prevent UI elements from being selected by trackball - android

So I have a Player view with seekbar and play/pause/rewind, etc. buttons, which are ImageButtons that have pressed and normal states, but no selected states.
Given that there are a number of android devices that have a trackball as alternate input (aside from the touchscreen), is there any way for me to prevent the trackball from focusing some of my UI elements?
Thing is, i want the trackball to be used solely for the seekbar, but I don't want the user to be able to scroll down/up to focus on the other buttons.
I tried setting focusable=false on the elements i don't want to get focus, but it doesn't work.
Is this even possible?

Tryusing
seekbar.requestFocus();
seekbar.setNextFocusUpId(seekbarid);
seekbar.setNextFocusDownId(seekbarid);
seekbar.setNextFocusLeftId(seekbarid);
seekbar.setNextFocusRightId(seekbarid);
This way the seekbar should always regains the focus even when trackball moves.

Related

Make onFocus event available on a touchable element in React Native on non-TVs

Is there any way to enable onFocus, onBlur etc. on Touchable-Elements on non-TVs devices?
The touchable elements event is not triggered, but the default feedback is visible when I use the physical keyboard.
I need simple dialogs on a Zebra mc3300. This device has a physical keyboard and when I show a dialog with a yes/no question, one button should have focus when the dialog becomes visible.
I'm not sure, maybe ref.current?.focus() works, when I press enter the key onPress is triggered, but i don't get any visible feedback which key has the focus. Only when I use the hardware button to switch to the next element and back again, the button became a different opacity.
Many thanks to you.

Android: Hiding view elements when Keypad comes up

Although I am pretty sure this is doable, I just wanted to double check with you all.
I need to hide certain UI elements(like checkbox, lables etc) on the screen when User taps on the edittext field, just before Keypad comes up and take up half the screen. Same should be visible once Keypad is removed from the screen. I am thinking of using View.GONEon those UI elements, but I am not sure how to get them back once the Keypad is removed from the screen.
I want you help in knowing if this is possible, if so how can revert it when Keypad is no more on the screen.
Thanks,
SKU

Android: Detect When Soft Keyboard Is About to Show?

Is there a way to detect when the keyboard is about to be presented in Android?
My problem is that I have a ListView with EditTexts in it. When the keyboard is about to be presented, these are quite often redrawn, causing an EditText that was JUST tapped to lose focus and require an extra tap.
My proposed solution is to monitor when the keyboard is about to be shown, check to see which view currently has focus, then after the keyboard is done being shown, restore focus to that view.
However, I have no idea how to detect when the keyboard is "about to be shown" in Android. How would I do this?
(I would also accept an alternative answer that addresses my actual problem: EditText losing focus when keyboard is displayed)
You could do it the other way, create an unique OnFocusChangedListener myListener and set it to all your EditTexts and put a switch inside and store which is the last view getting/losing focus

Android: soft keyboard efficient key press effect?

on softkeyboard, which one is better to give user a visual feedback during keypress:
1.redraw portion of button that was pressed to background canvas of main View to give pressed effect
2.each button has its own "pressed" View, and that View is set to visible (flashing) during keypress event (so no redraw needed but need more memory)
I know its trade-off between speed and memory usage, but I just want to know what you will do under this situation.
You wont be able to see the key because your finger will be covering it! The character being added to the focused text field might be enough.

Losing screen object auto-focus

I have a GridView displaying buttons to different screens of my app. When this grid screen, the first cell is selected. Is there a way to programmatically have no cells selected when the screen launches? Or do I have to hide the selector?
When this grid screen, the first cell is selected.
That should only be true if the user was using the navigator (D-pad, trackball, etc.) in the previous activity.
Is there a way to programmatically have no cells selected when the screen launches?
Generally, the user determines this based on whether they are in touch mode or not. You could try setSelection(-1) or something, but I would not be surprised if this fails to work.
Or do I have to hide the selector?
I would recommend just following the platform conventions. If the user is using the D-pad or trackball, they probably want to use the D-pad or trackball, and disabling the selector will simply make them frustrated with you and your app. Please see the article I linked to above for more details on touch mode and why it works the way it does.

Categories

Resources