1

I am searching how to move the focus from one fragment to another fragment.

I am watching to below page to implement the keyboard navigation. keyboard navigation

Our app is only provided to landscape table. So it has 2 fragments. (Left side, right side) And what I want to do is when I input "->" right arrow keyboard on left side fragment, how can I change the focus to the right side fragment? And it should be able to come back from contents fragment to menu fragment.

Is it possible? then Can I know a hint, please?

enter image description here


I am adding more details about this question.

This question is about focus navigation using the HW keyboard.

I already write the guide document link (https://developer.android.com/training/keyboard-input/navigation)

Using below attributes, I can move the focus. - android:nextFocusUp - android:nextFocusDown - android:nextFocusLeft - android:nextFocusRight

But our app is consist of 2 fragments. In the left menu fragment, I can move the focus using the arrow keyboard. And when I input "right arrow" or "enter" keyboard or anything, I want to move the focus to the right side contents fragment. And when I input the arrow keyboard, (up, down, left, right) the focus is moved in the right side fragment not left side.

But if I want to come back from the right side to left side, I want to do that.

For example, I moved the focus to the final view, and I input "right or down arrow", I should come back to the left side fragment.

Following the guide document (https://developer.android.com/training/keyboard-input/navigation), this is defined on the xml file.

It means I can move the focus only in the xml file.

What I want to do is change the focus beyond the xml file.

yoonhok
  • 2,575
  • 2
  • 30
  • 58
  • So you want to switch between fragments and keep the data while switching them in short? – Arahasya Oct 29 '18 at 08:07
  • My question is about the "Keyboard Navigation". In one activity view, there are no issue. But in case of 2 fragments, I want to use the "Keyboard Navigation" like one activity. – yoonhok Oct 29 '18 at 08:12
  • Your description of problem is confusing and what you want is unclear. So when You press arrow on keyboard what exactly do you want – Arahasya Oct 29 '18 at 08:18
  • If you want to communicate with two of this fragment then you can use interface for that. Once user click on "->" Right arrow call the interface method and other fragment should implements that interface. – Jaimin Thakkar Oct 29 '18 at 08:19
  • https://stackoverflow.com/a/22714222/10290109 – Arahasya Oct 29 '18 at 08:26
  • I apologize for any unclear questions. So I added more details. – yoonhok Oct 29 '18 at 08:36
  • I also have this problem, so how did you solve this problem? – Jack Lee May 10 '23 at 14:44

0 Answers0