• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Keyboard navigation using code

MCHammerT

Lurker
Jun 14, 2019
1
0
Let say for some reason I have gotten a code where the main activity will present a dialog to allow the user to confirm exit or just cancel, I would like to implement that the user can use the arrow key to move left and right or rotate back to the two buttons ( cancel or ok ), how do I do it in code ?
I found many solutions using the XML method where the view will have the android:nextFocusRight="@+id/button2". But how could this be done programmatically ?

Thank you very much.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones