我无法在Jetpack Compose 中使用 Coil加载此图像Image
如何在jet pack compose中将项目置于表面中心
@Composable
fun RoundedShapeWithIconCenter(
modifier: Modifier = Modifier,
parentSize : Dp,
parentBackgroundColor : Color,
childPadding : Dp,
icon : Painter,
iconSize : Dp,
iconTint : Color,
elevation : Dp = 0.dp,
isTextOrIcon : Boolean = false,
insideText : String = "",
insideTextColor : Color = colorResource(id = R.color.black),
fontSize: TextUnit = 16.sp
) {
Surface(
modifier = modifier.size(parentSize),
shape = RoundedCornerShape(50),
color = parentBackgroundColor,
elevation = elevation,
) {
if (isTextOrIcon) {
CommonText(value = insideText, fontSize = fontSize, …Run Code Online (Sandbox Code Playgroud) 列表适配器 diffutil 未更新 recyclerview 中的列表项。
当我从列表中添加或删除项目时它会起作用。isSelected : Boolean = false但不会像对象类中那样更新任何特定值
当列表中的对象类之一发生更改(例如一个对象类中的布尔值更改)时,如何更新 recyclerview 视图
谢谢
下面的适配器类
class CategoryMainAdapter(
var itemClick : CategoryItemClick,
var screenWidth : Int = 0
) : ListAdapter<CategoryModel, CategoryMainAdapter.CategoryMainViewHolder>(CategoryMainDiffUtils()) {
inner class CategoryMainViewHolder(val binding : CategorySingleListLayoutBinding) : RecyclerView.ViewHolder(binding.root)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CategoryMainViewHolder {
val binding = CategorySingleListLayoutBinding.inflate(LayoutInflater.from
(parent.context),
parent,
false
)
return CategoryMainViewHolder(binding)
}
override fun onBindViewHolder(holder: CategoryMainViewHolder, position: Int) {
val model = getItem(position)
holder.apply {
binding.apply {
mainLinearLayout.layoutParams.apply {
width = …Run Code Online (Sandbox Code Playgroud) android listadapter kotlin android-recyclerview android-diffutils