Android TV App - unable to select list item with remote

前端 未结 1 1958
醉酒成梦
醉酒成梦 2021-01-05 14:07

Currently I am working on Android TV app.

I have used Android Lean back support library.

I have added one ListView, but I can not able to select

相关标签:
1条回答
  • 2021-01-05 14:14

    Finally I got the solution after lots of R&D.

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

    Firstly, you have to keep focus of any one of items (i.e. Button, TextView, etc.) as below.

    And also, you have to apply its nextFocusDown, nextFocusLeft, nextFocusRight & nextFocusUp properties, so that it will fire its relevant event when you click TV remote navigation buttons.

    <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 refer to:

    1. Android User Interface Design: The Basics of Control Focus Order,
    2. Creating TV Navigation.
    0 讨论(0)
提交回复
热议问题