android-recyclerview 相关问题

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

GridLayoutManager java.lang.ArrayIndexOutOfBoundsException

当 recyclerview 显示在屏幕上时,我收到此错误,我将 GridLayoutManager 设置为我的 recyclerview 的布局管理器。(52 作为 spanCount) Java.Lang.ArrayIndexOutOfBoundsException:长度= 53; ...

回答 1 投票 0

项目经过圆形回收器视图

我创建了一个回收器视图,并添加了一个带有 2dp 描边的圆角矩形作为背景,但是当项目进出框架时,会越过圆角 我尝试添加填充和

回答 1 投票 0

通过Recyclerview列出的卡中的id检索数据

我在我的应用程序中发布了广告。 我从 firebase 中将广告作为列表拉出,并使用回收器适配器列出它们。使用视图模型。 每个广告中都有发布该广告的人的 ID。 我的问题...

回答 1 投票 0

Firebase 回收视图在 Android Studio 中不显示数据,仅显示空白暗白色背景

我按照有关在 android studio 中构建聊天应用程序的教程系列进行操作,并构建了一个附加了 Firebase 数据库的回收视图,但它没有显示。你可以在这张图片中看到,它只显示...

回答 1 投票 0

如何使用androidx.recyclerview.widget.RecyclerView?

这是RecyclerView: 在此输入图像描述 这是 CardView: 在此输入图像描述 但设计选项卡向我展示了这一点: 在此输入图像描述 我想尝试这样做: 输入图像描述...

回答 1 投票 0

RecyclerView GridLayoutAdapter - 如何居中项目

我正在将 RecyclerView 与 GridLayoutAdapter 一起使用。是否可以将项目水平或垂直居中? 我的项目布局: 我正在将 RecyclerView 与 GridLayoutAdapter 一起使用。是否可以将项目水平或垂直居中? 我的物品布局: <?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="match_parent" android:gravity="center" android:orientation="horizontal"> <ImageView android:id="@+id/item_photo_image_view" android:layout_width="@dimen/custom_photo_item_size" android:layout_height="@dimen/custom_photo_item_size" android:background="@drawable/custom_image_background" tools:src="@drawable/gallery_list_cars"/> </LinearLayout> 实际上是这样的:http://oi61.tinypic.com/34pjmtc.jpg 所需的布局应如下所示:http://oi62.tinypic.com/7e2t.jpg 将RecyclerView设置为wrap_content不起作用,它仍然使用所有可用空间。我想在 RecyclerView 中设置子重力应该是 LayoutManager 的责任。 你已经用那行做了: android:gravity="center" 有了这条线,您已经将 ImageView 水平和垂直居中了。 如果您只想要其中之一,请使用例如: android:gravity="center_horizontal" 我不知道你的问题到底是什么,我们甚至不知道 android:layout_width="@dimen/custom_photo_item_size" 您的 dimensions.xml... 中声明了哪个值 如果您想将整个Item居中,您需要声明: android:layout_gravity="Center" 但这没有任何意义,因为您在 GridView-Cell 中只有一种布局,并且您将 Item 的 rootView 声明为 android:width="match_parent" android:height="match_parent" 所以这只是给您的信息;) 如果您需要更好的支持,请提供更多信息。无论如何希望它有帮助 <androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content" android:layout_gravity="center_horizontal"> Adapter的xml父布局集 安卓:layout_width =“match_parent” 机器人:layout_gravity =“center_horizontal”

回答 2 投票 0

如何检索RecyclerView中所有复选框的值?

数据成功添加到firebase中, 但是它只发送了recyclerView的3个数据。 基于什么chatGpt 由于屏幕上只有 3 个 recyclerView,这就是为什么只有 3 个成功检索 这里是...

回答 1 投票 0

RecyclerView 不显示列表的最后一行

当我使用条件在 recyclerView 适配器中设置文本项时,最后一行不显示?我不知道该怎么做 请帮我。 ShopCategoriesAdapter 类(var list:List 当我使用条件在 recyclerView 适配器中设置文本项时,最后一行不显示?我不知道该怎么做 请帮助我。 class ShopCategoriesAdapter (var list:List<CategoryModel>) : RecyclerView.Adapter<ShopCategoriesAdapter.ViewHolder>() { inner class ViewHolder(private val binding: ListItemShopCategoriesBinding) : RecyclerView.ViewHolder(binding.root) { fun bind(categoryModel: CategoryModel) { if (categoryModel.level == 1) binding.textViewListItemShopCategoriesCategoryName.text = categoryModel.name } } override fun onCreateViewHolder( parent: ViewGroup, viewType: Int ): ShopCategoriesAdapter.ViewHolder = ViewHolder( ListItemShopCategoriesBinding.inflate( LayoutInflater.from(parent.context), parent, false ) ) override fun onBindViewHolder(holder: ShopCategoriesAdapter.ViewHolder, position: Int) { holder.bind(list[position]) } override fun getItemCount(): Int { return list.size } } 检查您的回收视图的布局设置。请确保 recyclerview 的布局会扰乱内容的包装。我以前已经见过这个问题了。在这个问题中,解决方案与适配器无关,它与布局设置有关。

回答 1 投票 0

Kotlin:文本从 RecyclerView 中的按钮消失

我设置了一个包含按钮列表的 RecyclerView。列表的长度和每个按钮的文本应来自数据库查询的结果(我在其中查找数据库中保存的所有食谱)。

回答 1 投票 0

RecyclerView 未显示在 Fragment 中

我正在尝试将 RecyclerView 添加到片段,但没有成功。我已遵循本指南,但其中 RecyclerView 添加到 MainActivity,因此我尝试对其进行调整。但是,我不能...

回答 1 投票 0

如何制作一个简单的数据输入应用程序,其中两个活动相互导航

我想制作一个简单的数据输入应用程序,该应用程序从主要活动开始,并在用户获取所有输入后询问用户来自图库的信息和图像 URI

回答 1 投票 0

嵌套 RecycleView 中的 ItemDecoration 在父 RecycleView 中添加新项目后会更改填充

我在做什么 我使用 DelegateAdapters 在父 RecyclerView 中显示不同的部分。 在此代码中,我添加了两个部分(AuthorTracksDelegateItem 和 NewReleasesDelegateItem),它们具有

回答 1 投票 0

RecyclerView 没有显示来自 json 数组的数据

我已经创建了Recyclerview,我想从数据库检索数据到android recyclerview。我通过php从mysqlserver检索数据到JSON格式。但是数据没有显示在recyclerview中...

回答 1 投票 0

RecyclerView 未填充数据

我正在尝试使用 SQLite 数据库内容中的数据加载 recyclerview。但它不起作用 这就是我所做的 活动课 公共类 ViewMembership 扩展 AppCompatActivity { 公关...

回答 1 投票 0

Android PagerSnapHelper 在用户移动到下一页数据之前预加载下一页数据(如 ViewPager2 中的 setOffscreenPageLimit)

我正在开发一款应用程序,它通过媒体滑块显示 Instagram 类型的帖子提要。我使用 Recyclerview 和 PagerSnapHelper 开发了一个后媒体滑块,以水平方向显示媒体列表...

回答 1 投票 0

如何在 Recylerview 中的 CardView 周围创建一些边距

我有以下 CardView 的 XML 布局文件,然后将其放入 Recylerview 中: 我有以下用于 cardView 的 XML 布局文件,然后将其放入 Recylerview 中: <?xml version="1.0" encoding="utf-8"?> <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/cardView_itemLevel" android:layout_width="150dp" android:layout_height="150dp" xmlns:app="http://schemas.android.com/apk/res-auto" app:cardCornerRadius="10dp" android:layout_marginTop="12dp" android:layout_marginStart="12dp" android:layout_marginBottom="12dp" android:layout_marginEnd="12dp" app:cardPreventCornerOverlap="true" app:cardElevation="0dp" app:cardUseCompatPadding="false" app:contentPaddingBottom="2dp"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/imageView_levelImage" android:layout_width="75dp" android:layout_height="75dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.507" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="5dp" /> <TextView android:id="@+id/textView_bestResultThisLevel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" android:textSize="10sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/imageView_levelImage" /> <TextView android:id="@+id/textView_CO2SavingsTotalThisLevel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="3dp" android:textSize="10sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView_bestResultThisLevel" /> <TextView android:id="@+id/textView_gasSavingsTotalThisLevel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="3dp" android:textSize="10sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView_CO2SavingsTotalThisLevel" /> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.cardview.widget.CardView> 我使用所有方向的边距值,但输出仍然如下所示: 不幸的是,在垂直维度上(片段始终以横向模式显示),不同卡片视图周围没有边距。我的问题是如何创建这样的边距。 将卡片视图添加到另一个布局。 <RelativeLayout 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="wrap_content" android:padding="2.5dp"> <androidx.cardview.widget.CardView android:id="@+id/card_view" android:layout_width="match_parent" android:layout_height="match_parent" app:cardBackgroundColor="@color/tintBackground" app:cardCornerRadius="8dp" app:cardElevation="0dp"> <ImageView android:id="@+id/image_view_center" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:src="@drawable/use_default_icon"/> </androidx.cardview.widget.CardView> </RelativeLayout>

回答 1 投票 0

如何从 firebase RecyclerView 中删除项目

我目前正在 Firebase RecyclerView 的帮助下添加朋友,其中如果用户点击“添加”按钮,他就会被添加到数据库中,并且需要永久删除所点击的项目......

回答 4 投票 0

如何阻止RecyclerView一遍又一遍地重复相同的4个项目[关闭]

我有一个包含 20 个项目的 RecyclerView,但它只是重复其中 4 个项目 5 次,而不是实际的 20 个项目。 我清除列表并每 5 分钟刷新一次数据,所以我不认为这是因为重复

回答 1 投票 0

如何在滚动过程中停止更改回收器视图中的项目数据

在我的情况下,数据的初始加载是完美的,但是当我在某个位置滚动 recyclerView 时,即使状态不等于 1,textView 也是可见的。 适配器 = 新的 FirebaseRecyclerAdapter<...

回答 2 投票 0

如何在Android Recyclerview中按时间顺序排列项目

我有一个带Cardview的Recylcerview,我使用代码设置布局 recyclerView = 绑定.recyclerView; recyclerView.setHasFixedSize(true); GridLayoutManager 布局管理器 ...

回答 1 投票 0

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