Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android电视应用程序-无法使用遥控器选择列表项_Android_Avd_Android Tv_Leanback - Fatal编程技术网

Android电视应用程序-无法使用遥控器选择列表项

Android电视应用程序-无法使用遥控器选择列表项,android,avd,android-tv,leanback,Android,Avd,Android Tv,Leanback,目前我正在开发Android电视应用程序 我已经使用了Android精益支持库 我已经添加了一个列表视图,但是我无法使用真实设备的遥控器从列表视图中选择任何项目。然而,我可以通过鼠标在我的Android虚拟设备上选择listView项 以下是我的listView示例代码: customViewOrders = new CustomViewOrders(getActivity().getBaseContext(), arrayViewOrders); lstViewOrder.setAdapter

目前我正在开发Android电视应用程序

我已经使用了Android精益支持库

我已经添加了一个
列表视图
,但是我无法使用真实设备的遥控器从列表视图中选择任何项目。然而,我可以通过鼠标在我的Android虚拟设备上选择listView项

以下是我的listView示例代码:

customViewOrders = new CustomViewOrders(getActivity().getBaseContext(), arrayViewOrders);
lstViewOrder.setAdapter(customViewOrders);
这里,
ArrayViewers
是我的ArrayList,其中包含从JSON Web服务接收的数据

以下是我的JSON响应:

{
   "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"
      }
   ]
}
我还在AndroidManifest.xml文件中添加了以下功能:

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


因此,我的问题是:如何在远程设备的帮助下在真实设备中选择任何东西(即列表项、按钮)

经过大量的研发,我最终得到了解决方案

下面是我使用安卓电视遥控器进行定向导航的解决方案

首先,您必须保持以下任一项的焦点(即
按钮
文本视图
,等等)

此外,您还必须应用其
nextFocusDown
nextFocusLeft
nextFocusRight
nextFocusUp
属性,以便在您单击电视远程导航按钮时触发相关事件

<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>

android:text=“@string/signout”
android:textAppearance=“?android:textAppearanceMedium”>
有关更多信息,请参阅:

  • ,

  • 请添加您得到的JSON响应..@Kamal-我添加了JSON响应。