2016-12-01 8 views
0

メインメニューを表示するレイアウト、サブメニューを表示するレイアウト、詳細メニューを表示するレイアウトの3つのレイアウトがあります。キーボードの矢印ボタンを使用してこれらのレイアウトを移動する必要があります。メインメニューからサブメニューへ、サブメニューから詳細メニューへ、 へと移動しますが、問題は私が詳細メニューに入っているときにサブメニューに上ることができないことです。私は、プロパティandroid:nextFocusUpを使用してみましたが、それは私のためには機能しませんでした。異なるレイアウト間でフォーカスを切り替える方法

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#000000" > 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#1c1c1c" 
      android:layout_marginLeft="100dp" 
      android:layout_marginRight="100dp" 
      > 

      <LinearLayout 
      android:id="@+id/pagelogolayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:background="@drawable/logoborder"> 

     <ImageView 
      android:id="@+id/logoimage" 
      android:layout_width="170dp" 
      android:layout_height="90dp" 
      android:layout_marginTop="5dp" 
      android:background="@drawable/listpagelogo" 
      android:layout_marginLeft="10dp" 
      android:layout_marginBottom="15dp" 
      /> 

    </LinearLayout> 


    <RelativeLayout 
     android:id="@+id/mainmenu" 
     android:layout_width="match_parent" 
     android:layout_height="90dp" 
     android:layout_below="@+id/pagelogolayout" 
     android:orientation="horizontal" 
     android:background="@drawable/main_menu_border" 
     android:nextFocusDown="@+id/submenu" 
     android:focusable="true"> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/submenu" 
     android:layout_width="match_parent" 
     android:layout_height="70dp" 
     android:layout_below="@+id/mainmenu" 
     android:orientation="horizontal" 
     android:background="@drawable/sub_menu_border" 
     android:nextFocusDown="@+id/container" > 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/container" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_below="@+id/submenu" 
     android:layout_marginTop="30dp" 
     android:layout_marginLeft="30dp" 
     android:nextFocusUp="@+id/submenu" 
     /> 

     </RelativeLayout> 
</RelativeLayout> 

答えて

0
view.requestFocus(); 

注:お使いのレイアウトがあまりにも多くのネストされたレイアウトを持っている、それはアプリのパフォーマンスがダウン

であることを確認します
関連する問題