android-recyclerview 相关问题

RecyclerView小部件是ListView和GridView的更高级和灵活的版本。

GridLayoutManager spancount 不起作用

我在 android studio java 工作。该应用程序运行,但它仅在一列中显示回收器视图中的项目,而所需的行为是显示两列。我尝试改变跨度...

回答 1 投票 0

嵌套滚动视图内的RecyclerView最初加载速度很慢

我有一个recyclerView,如下所示。它位于一个片段内,该片段是应用程序启动时显示的第一个屏幕。在我添加 NestedScrollView 之前,recyclerView 用于加载数据...

回答 2 投票 0

RecyclerView水平线性布局管理器导致recyclerview不显示

首先我的代码是这样的 首先我的代码运行 <androidx.recyclerview.widget.RecyclerView android:id="@+id/rvPrices" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layout_constraintTop_toTopOf="parent" tools:itemCount="3" tools:listitem="@layout/business_item_fire_job_price_des" /> 在回收器视图 xml 中设置布局管理器 问题是,当项目添加到适配器时,我可以看到它调用了bindData的日志,但在某些情况下,recyclerview消失了,任何人都可以解释为什么吗? 似乎当 UI 刷新有点滞后时就会出现问题(在 android studio miror 设备中,问题发生得更频繁) 我尝试将布局管理器更改为垂直,它工作正常,但我希望回收器视图水平布局 我现在有一个解决方法 在代码中设置布局管理器,如下所示: 将 isMeasurementCacheEnabled 设置为 false 解决问题 有人能告诉为什么吗? rvPrices.layoutManager = LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false).apply { isMeasurementCacheEnabled = false }

回答 1 投票 0

ViewPager2 从 API 获取数据无法正常工作

lifecycleScope.launch { viewModel.nowPlayingMovieList.collect{ sliderAdapter.submitData(it) } } sliderAdapter.setOnItemClickListener { ...

回答 1 投票 0

未连接适配器;跳过布局 ||安卓异常

Logcat 我的应用程序中有一个底部导航栏,在应用程序启动时,它首先显示来自 API 的 recyclerview 数据,但如果我导航到其他片段并返回,它不会加载。

回答 1 投票 0

LiveDataobserve() 没有被调用

Не понимаю,почему при добавлении элемента в список программа не считывает изменения и не вызввает метод 观察。 数据类 ListOfItems( var 列表:MutableList ) 数据类项目( ...

回答 1 投票 0

如何使用对象动画器设置 RecyclerView 中项目的背景颜色?

我有一个 RecyclerView,其中某些项目出现在屏幕上时,其背景颜色应以动画方式从粉色变为透明,持续 6 秒。 但问题是除此之外...

回答 1 投票 0

如何让RecyclerView项目“弹出”到位?

我有显示 LinearLayout“按钮”的回收器视图 我想显示适合回收器的 x 按钮而不切断按钮,并且在滚动后如果按钮被切断它会移动 u...

回答 1 投票 0

实现Recyclerview过滤器时出现indexoutofboundException

我在实现 recyclerView 过滤器时遇到 java.lang.IndexOutOfBoundsException 。 onBindViewHolder方法出现错误,位置值大于过滤后的列表,所以导致

回答 1 投票 0

Android:以编程方式创建 RecyclerView 不起作用

我在xml中有一个RecyclerView,如下所示: 我在 xml 中有一个 RecyclerView,如下所示: <LinearLayout android:id="@+id/llTestMenuMain" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/gradient" android:orientation="vertical"> <androidx.recyclerview.widget.RecyclerView android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" android:id="@+id/rv" /> </LinearLayout> 并使用它来显示动态按钮列表,如下所示: int buttonFontSize = 20; RecyclerView rv = findViewById(R.id.rv); LinearLayoutManager llm = new LinearLayoutManager(this); rv.setLayoutManager(llm); adapter = new RVAdapter_ButtonList(tests, null, this, buttonFontSize); rv.setAdapter(adapter); rv.setVisibility(View.VISIBLE); 一切都工作正常,但现在所有垂直显示的按钮都将水平显示并分组到类别中,所以我需要动态创建 RecyclerViews,我从一个简单的例子开始,只有一个接下来的方式没有成功,显示空白屏幕: int buttonFontSize = 20; RecyclerView rv = new RecyclerView(this); RecyclerView.LayoutParams params = new RecyclerView.LayoutParams( RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT ); rv.setLayoutParams(params); LinearLayout llTestMenuMain = findViewById(R.id.llTestMenuMain); llTestMenuMain.addView(rv); LinearLayoutManager llm = new LinearLayoutManager(this);rv.setLayoutManager(llm); adapter = new RVAdapter_ButtonList(tests, null, this, buttonFontSize); rv.setAdapter(adapter); rv.setVisibility(View.VISIBLE); 任何关于为什么我无法使动态创建的 RecyclerView 工作的帮助将不胜感激。 编辑1: 我不知道它是否有任何帮助,但注意到动态创建 RV 适配器“onBindViewHolder”永远不会被调用(当然,itemCount > 0),当在 XML 中创建 RV 时会调用它。找不到解决方案...:( 编辑2: 也尝试过 runOnUiThread(new Runnable() { @Override public void run() { adapter.notifyDataSetChanged(); } }); 以防万一,也无济于事。 尝试用以下代码替换您的代码: int buttonFontSize = 20; LinearLayout llTestMenuMain = findViewById(R.id.llTestMenuMain); RecyclerView rv = new RecyclerView(this); RecyclerView.LayoutParams params = new RecyclerView.LayoutParams( RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT ); rv.setLayoutParams(params); LinearLayoutManager llm = new LinearLayoutManager(this); adapter = new RVAdapter_ButtonList(tests, null, this, buttonFontSize); rv.setAdapter(adapter); rv.setLayoutManager(llm); rv.setVisibility(View.VISIBLE); llTestMenuMain.addView(rv); 我发现将以编程方式创建的 RecyclerView 放入 ScrollView 中可以使其“神奇地”可见。

回答 2 投票 0

如何将大量项目从 Firebase 加载到 RecyclerView?

我正在寻找一种有效的方法来在我的 RecyclerView 中检索和显示来自 Firestore 的 500 多组数据。每个数据集包含三个字符串和一个存储引用(例如,tools/ima...

回答 1 投票 0

DiffUtil 不同大小列表的回调

我正在使用自定义实现 DiffUtil 回调比较两个列表以查找它们之间的差异,但这两个列表具有不同的大小,当我记录正在比较的元素时...

回答 1 投票 0

在 Kotlin 中的 RecyclerView 之间传输项目

我正在构建一个 Android 应用程序,我试图通过单击按钮使项目在列表之间移动(从列表 A 中删除并移动到列表 B),这对我不起作用,有时项目 ar ...

回答 1 投票 0

滚动 Android TV 时如何阻止 RecyclerView 与 TextView 重叠

我有一个 Android TV 应用程序,它在 TextView 下方有一个 RecyclerView。一切看起来都很棒,直到我单击第三个项目,导致 RecyclerView 覆盖 TextView。 我有一个 Android TV 应用程序,它在 TextView 下方有一个 RecyclerView。一切看起来都很棒,直到我单击第三个项目,导致 RecyclerView 覆盖 TextView。 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:focusable="false" android:focusableInTouchMode="false" android:keepScreenOn="true"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:clipToPadding="false" android:clipChildren="false" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent"> <TextView android:id="@+id/dateTV" android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="18sp" android:layout_marginStart="@dimen/homeHorizontalMargin" android:paddingBottom="20dp" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/recyclerView" android:layout_below="@id/dateTV" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:layout_marginHorizontal="@dimen/epgRVHorizontalMargin" android:focusable="false" android:focusableInTouchMode="false" android:descendantFocusability="afterDescendants" /> </RelativeLayout> </androidx.constraintlayout.widget.ConstraintLayout> 如何阻止 RecyclerView 与 TextView 重叠? 您的 RecyclerView 父布局具有以下属性 android:clipToPadding="false" android:clipChildren="false" 因此,当您滚动RecyclerView时,它将与布局中的其他视图重叠。 您可以将其删除。为什么在这里使用这个属性有什么具体原因要在屏幕上设计其他视图吗? 或者您有 ConstraintLayout 作为根布局,那么为什么您再次添加 RelativeLayout 并将 RecyclerView 放入此布局中。 您可以像下面这样设计您的 XML 布局 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:focusable="false" android:focusableInTouchMode="false" android:keepScreenOn="true"> <TextView android:id="@+id/dateTV" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/homeHorizontalMargin" android:paddingBottom="20dp" android:textSize="18sp" app:layout_constraintTop_toTopOf="parent" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="0dp" android:layout_below="@id/dateTV" android:layout_marginHorizontal="@dimen/epgRVHorizontalMargin" android:layout_marginTop="20dp" android:descendantFocusability="afterDescendants" android:focusable="false" android:focusableInTouchMode="false" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@id/dateTV" /> </androidx.constraintlayout.widget.ConstraintLayout>

回答 1 投票 0

如何在没有动画的情况下更新RecyclerView项目?

我有一个RecyclerView。当我单击 RecyclerView 中某个项目内的按钮时,我想更改该项目中视图的颜色。以下是我的代码并且运行良好。但是,问题是我...

回答 6 投票 0

在kotlin中firebase Documentlistener在该方法中调用时多次调用onBindViewHolder方法(无限调用)

这是 Reyclerview 的适配器类 我的问题是当我在 onBindViewHolder 方法中调用 firebase 文档时,由于 addSnapshotListener 的回调,它调用无限循环,因为我需要...

回答 1 投票 0

recyclerView 中的可重用元素会调用哪些生命周期方法?

我有一个 RecyclerView,我向其传递文本并希望了解以下内容:如果 lineCount > 3,则显示展开按钮,将椭圆大小设置为结束状态并使 maxLines = 3。 要做到这一点...

回答 1 投票 0

使用recyclerView时如何修复底部导航栏?

我正在设计一个带有回收器视图和底部导航栏的页面,但问题是底部导航栏隐藏在底部,当我向上滚动回收器视图时,底部导航栏可见...

回答 1 投票 0

RecyclerView Item EditText 使用 TextWatcher 和 ROOM 数据库在其中写入新值后不会更改默认值

我有这个问题:我正在创建一个应用程序,用户在其中添加一个“集合”到练习中,当他单击“+”按钮时,它会将一个新的“集合”添加到活动中的集合列表中。 ...

回答 1 投票 0

编辑:使用 TextWatcher 和 ROOM 数据库,RecyclerView 项目 EditText 在写入新值后不会更改默认值

编辑:添加了 SetDao 和 SetItem。 我有这个问题:我正在创建一个应用程序,用户在其中添加一个“集合”到练习中,当他单击“+”按钮时,它会向其中添加一个新的“集合”...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.