Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.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_Android Tv_Ott - Fatal编程技术网

Android电视:回收器视图未滚动

Android电视:回收器视图未滚动,android,android-tv,ott,Android,Android Tv,Ott,我在安卓电视上用回收器视图显示了一个物品列表。但我的列表并没有滚动,而是专注于它。请帮我解决这个问题 private void initRecyclerView(){ ArrayList<String> categoryList = (ArrayList<String>) getIntent().getSerializableExtra("categoryList"); RecyclerView recyclerView=(Recyc

我在安卓电视上用回收器视图显示了一个物品列表。但我的列表并没有滚动,而是专注于它。请帮我解决这个问题

private void initRecyclerView(){
    ArrayList<String> categoryList = (ArrayList<String>) getIntent().getSerializableExtra("categoryList"); 
    RecyclerView recyclerView=(RecyclerView) findViewById(R.id.categoryRecyclerView);
    RecyclerViewAdapter adapter=new RecyclerViewAdapter(this,categoryList);
    System.out.println("investmentRecyclerView array: " + categoryList);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
private void initRecyclerView(){
ArrayList categoryList=(ArrayList)getIntent().getSerializableExtra(“categoryList”);
RecyclerView RecyclerView=(RecyclerView)findViewById(R.id.categoryRecyclerView);
RecycleServiceAdapter=新的RecycleServiceAdapter(这是categoryList);
System.out.println(“investmentRecyclerView数组:“+categoryList”);
recyclerView.setAdapter(适配器);
recyclerView.setLayoutManager(新的LinearLayoutManager(本));
}

项目的布局设置可聚焦=true

例如,
list_item.xml
是RecycerlView的项:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/item_selector"
    android:focusable="true">
    <TextView
        android:id="@+id/topic"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:textColor="#ffffff"
        android:gravity="center"/>
</LinearLayout>

要查看其是否聚焦,请将此扇区添加为可绘制,并相应地添加图像:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/black" android:state_pressed="true"/>
    <item android:drawable="@color/black" android:state_selected="true"/>
    <item android:drawable="@color/black" android:state_focused="true"/>

    <item android:drawable="@color/lightblue"></item>
</selector>

谢谢您的回复。这是我的XML代码


您必须使用LeanbackSDK中的垂直网格视图水平网格视图而不是回收视图

<androidx.leanback.widget.HorizontalGridView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
android:id="@+id/row_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
lb:rowHeight="wrap_content"
style="?attr/rowHorizontalGridStyle" />


你能发布你的XML布局吗?当我发布时,android:background=“@drawable/item\u selector”它将被拉伸。设计问题。然后使用9修补它的滚动但不能聚焦?我认为你做错了什么,或者它有聚焦但你看不见。为每个项目设置背景选择器。