Dealing with d-pads and focus?

Dave O

Well-Known Member
Licensed User
Longtime User
Was just trying my first app on a friend's (old) Android phone, which has a D-pad (4-way buttons + select button).

I noticed that I could use the direction buttons to select controls on the screen, then the Select button to activate them (i.e. click event), but there was no visible indicator of where the focus was, at least for the buttons.

Is there a recommended way to support d-pad use, showing the focus move around? I saw some posts about enabling/disabling focus in "touch mode" and so on, but I'm not sure what a "standard" app is supposed to do.

Just seems weird to have the d-pad work, but without visual feedback about the currently focused control.

Thoughts?
 

Dave O

Well-Known Member
Licensed User
Longtime User
Ah, good point. Forgot to say that I'm using StateListDrawable buttons - some are icon buttons (BitmapDrawable) and some are simple ColorDrawables.

I have ...Enabled and ...Pressed drawables defined, but is there one for focus? Perhaps the ...Selected entry? (The docs didn't have much on this, or I missed it more likely ;^)
 
Upvote 0

Dave O

Well-Known Member
Licensed User
Longtime User
Hmm, I've tried adding the Selected state (after Pressed, before Enabled, as far as I was able to determine by looking at the Android dev pages), but it's not showing up when I use an emulated device with a d-pad.

(I can use the d-pad to move up and down and activate the buttons, showing their Pressed state, but no visual change when I change focus.)

Nor have I been able to find a code example that uses the Selected state. Has anyone got this state to work?

Thanks!
 
Upvote 0

aidymp

Well-Known Member
Licensed User
Longtime User
Is there an example of this? I too am using Statelist drawable buttons. But some of my clients use a remote control to use my app. it contains 8 buttons and 2 spinners and an edittext box! using the remote they can navigate the spinners, and the edittext box. but they have to guess what button is highlighted, also the buttons don't seem to follow a specific order! is there a way to order them?

as in this instance
2690409_orig.png

using the arrow keys it goes spinner 1 & 2 then button Delete Packages, it misses the Download button out?

ideally if i could detect focus i presume adding

something like

B4X:
Sub button1_State_Focused
Button1.TextColor=Colors.blue
End Sub

but that doesn't work?

Any ideas

Thanks
 
Upvote 0

luisftv

Member
Licensed User
Longtime User
Can some one post a working sample project file, please, please, please... one that works with D-pads... or Android TV's control remotes.
 
Upvote 0
Top