Android TV App - it is not possible to select a list item using the remote control

I am currently working on an Android TV application.

I used Android Lean support support.

I added one ListView , but I can’t select any item from the View list with a real remote device. However, I can select the listView item on my Android device with the mouse.

Here is my listView code example:

 customViewOrders = new CustomViewOrders(getActivity().getBaseContext(), arrayViewOrders); lstViewOrder.setAdapter(customViewOrders); 

Here arrayViewOrders is my ArrayList that contains the data retrieved from the JSON web service.

Here is my JSON answer:

 { "order":[ { "0":"13829CF", "gen_id":"13829CF", "1":"17534CF", "2":"Complete", "ord_status":"Complete", "3":"Online Preview", "sta_name":"Online Preview", "4":"2015-10-27 00:00:00", "image":"cinereel", "placed_from":"web" } ] } 

I also added the following functions in the AndroidManifest.xml file:

 <uses-feature android:name="android.hardware.touchscreen" android:required="false" /> <uses-feature android:name="android.hardware.faketouch" android:required="true" /> 

So my question is: how to select something (i.e. a list item, button) in a real device using a remote?

+5
source share
1 answer

Finally, I got the solution after a lot of R & D.

Here is my solution for directional navigation using Android TV remote.

First, you need to focus on any of the elements (i.e. Button , TextView , etc.), as shown below.

In addition, you must apply your properties nextFocusDown , nextFocusLeft , nextFocusRight and nextFocusUp so that it nextFocusUp corresponding event when you press the buttons on the TV remote control.

 <Button android:id="@+id/btnSignout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/tvUserName" android:layout_marginTop="2dp" android:layout_toLeftOf="@+id/ivUser" android:width="100dp" android:nextFocusRight="@+id/ivUser" <!-- On click of right arrow button, focus will be move to ivUser id --> android:nextFocusUp="@+id/tvUserName" <!-- On click of up arrow button, focus will be move to tvUserName id --> android:text="@string/signout" android:textAppearance="?android:textAppearanceMedium"> <requestFocus></requestFocus> </Button> 

For more information, you can contact:

+4
source

Source: https://habr.com/ru/post/1240339/


All Articles