2

で方向パッド ナビゲーションを使用する必要があるアプリを開発していますRecyclerView。私の問題はandroid:focusable=true、(news_items) を設定してitems.xmlも機能しないように見えることです。

私の質問は、どのように D-pad ナビゲーションを に実装すればよいRecyclerViewですか?

RecyclerView、次のレイアウト内にあります。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

         />
    <TextView
        android:id="@+id/emptyView"
        android:visibility="gone"
        tools:visibility="visible"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=":( \n No news available"
        android:textSize="@dimen/fsn_emty_text"
        android:layout_gravity="center_vertical"
        android:gravity="center_horizontal"
        android:paddingEnd="@dimen/activity_horizontal_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingStart="@dimen/activity_horizontal_margin"
        />

</FrameLayout>

news_items.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/news_ripple"
    android:clickable="true"
    android:focusable="true"
    android:orientation="vertical"

    >


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.15"
                android:background="?attr/colorAccent"

                />


            <LinearLayout

                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/ni_margin"
                android:layout_weight="9"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/tvTitulo"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:gravity="left"
                    android:textColor="?android:attr/textColorPrimary"
                    tools:text="Titulo" />

                <TextView
                    android:id="@+id/tvFecha"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="left"
                    tools:text="Fecha" />

                <TextView
                    android:id="@+id/tvPublisher"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="left"
                    tools:text="Publisher" />
            </LinearLayout>

        </LinearLayout>
    </LinearLayout>


</LinearLayout>

更新:これは私が今受け取っているフォーカスの順序です:赤い色は私が今得ているフォーカスの順序です。タブから下に1回クリックすると、RecyclerView(reycclerview全体)がフォーカスを取得し、もう1回クリックしますAdMob (黒で表示) がフォーカスされます。青い矢印は、RecyclerView 内で必要なものです

ここに画像の説明を入力

4

1 に答える 1