2016-01-11 29 views
5

目前我正在開發Android TV應用程序。Android TV App - 無法選擇遠程列表項目

我已經使用Android Lean支持庫。

我已經添加了一個ListView,但我無法使用真實設備的遙控器從listView中選擇任何項目。不過,我可以在鼠標的幫助下,在我的Android虛擬設備上選擇listView項目。

這裏是ListView中的我的示例代碼:

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

這裏,arrayViewOrders是我的ArrayList其含有來自web服務JSON接收到的數據。

這裏是我的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" /> 

所以,我的問題是:如何選擇什麼(即列表項,按鈕)在真正的設備與遠程幫助?

+0

請添加JSON響應你正在.. – Kamal

+0

@Kamal - 我已經添加了JSON響應。 –

回答

4

最後我得到了很多[R & D.

的後的溶液

下面是使用Android TV遙控器的方向導航我的解決方案。

首先,您必須關注下列任何一項(即Button,TextView等)。

而且也,你必須申請其nextFocusDownnextFocusLeftnextFocusRight & 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> 

欲瞭解更多信息,可以參考:

  1. Android User Interface Design: The Basics of Control Focus Order
  2. Creating TV Navigation