当前位置: 首页 > news >正文

侧滑置顶,取消置顶

第一步:布局

<?xml version="1.0" encoding="utf-8"?>
<com.ddmh.magic.camera.ui.widget.SwipeMenuLayout 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="60dp"android:layout_marginTop="12dp"android:clickable="true"app:ios="false"app:leftSwipe="true"app:swipeEnable="true"><androidx.constraintlayout.widget.ConstraintLayoutandroid:id="@+id/cst_out"android:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:id="@+id/tv_team_name_short"android:layout_width="60dp"android:layout_height="match_parent"android:background="@drawable/bg_5493f7_4radius"android:gravity="center"android:text="xxxx"android:textColor="#ffffffff"android:textSize="18sp"app:layout_constraintLeft_toLeftOf="parent" /><TextViewandroid:id="@+id/tv_top_tips"android:layout_width="32dp"android:layout_height="18dp"android:background="@drawable/bg_e0e0e0_4radius"android:gravity="center"android:text="置顶"android:textColor="#ff878f99"android:textSize="10sp"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintTop_toTopOf="parent" /><TextViewandroid:id="@+id/tv_team_name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="8dp"android:ellipsize="end"android:maxWidth="250dp"android:singleLine="true"android:text="xxx"android:textColor="#ff1d2129"android:textSize="16sp"app:layout_constraintBottom_toTopOf="@+id/tv_team_day"app:layout_constraintHorizontal_weight="1"app:layout_constraintLeft_toRightOf="@+id/tv_team_name_short"app:layout_constraintTop_toTopOf="@+id/tv_team_name_short" /><TextViewandroid:id="@+id/tv_admin"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="8dp"android:background="@drawable/bg_ff615d_2radius"android:paddingLeft="7dp"android:paddingTop="5dp"android:paddingRight="7dp"android:paddingBottom="5dp"android:text="主xx员"android:textColor="#ffff615d"android:textSize="10sp"app:layout_constraintLeft_toRightOf="@+id/tv_team_name"app:layout_constraintTop_toTopOf="@+id/tv_team_name" /><ImageViewandroid:id="@+id/tv_team_day"android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/icon_today"app:layout_constraintBottom_toBottomOf="@+id/tv_team_name_short"app:layout_constraintLeft_toLeftOf="@+id/tv_team_name"app:layout_constraintTop_toBottomOf="@+id/tv_team_name" /><TextViewandroid:id="@+id/tv_takephots_peoples"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="@dimen/dp_4"android:text="xxxx"android:textColor="#ff878f99"android:textSize="12sp"app:layout_constraintBottom_toBottomOf="@+id/tv_team_day"app:layout_constraintLeft_toRightOf="@+id/tv_team_day"app:layout_constraintTop_toTopOf="@+id/tv_team_day" /><TextViewandroid:id="@+id/tv_pic_num"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="xxx"android:textColor="#ff878f99"android:textSize="12sp"app:layout_constraintBottom_toBottomOf="@+id/tv_takephots_peoples"app:layout_constraintLeft_toRightOf="@+id/tv_takephots_peoples"app:layout_constraintTop_toTopOf="@+id/tv_takephots_peoples" /></androidx.constraintlayout.widget.ConstraintLayout><LinearLayoutandroid:id="@+id/ll_top"android:layout_width="90dp"android:layout_height="match_parent"android:background="@color/color_gray"android:gravity="center"><TextViewandroid:id="@+id/tv_top"android:layout_width="wrap_content"android:layout_height="wrap_content"android:gravity="center"android:text="置顶"android:textColor="@color/white"android:textSize="16sp" /></LinearLayout>
</com.ddmh.magic.camera.ui.widget.SwipeMenuLayout>

第二步:适配器

class TeamItemAdapter(var list: ArrayList<TeamListBean>?) :BaseQuickAdapter<TeamListBean, BaseViewHolder>(R.layout.item_team_member, list) {override fun convert(holder: BaseViewHolder, item: TeamListBean) {holder.setText(R.id.tv_team_name_short, CommonUtils.getBeforeTwoStr(item.teamName))holder.setText(R.id.tv_team_name, item.teamName)holder.setText(R.id.tv_takephots_peoples, "已xx数:2")holder.setGone(R.id.tv_top_tips, !item.topFlag)holder.setText(R.id.tv_pic_num, "照片:2")when (item.roleType) {1 -> {holder.setText(R.id.tv_admin, "主管理员")holder.setTextColor(R.id.tv_admin,AppContext.appContext.resources.getColor(R.color.color_ff615d))holder.setBackgroundResource(R.id.tv_admin, R.drawable.bg_ff615d_2radius)}2 -> {holder.setText(R.id.tv_admin, "管理员")holder.setTextColor(R.id.tv_admin,AppContext.appContext.resources.getColor(R.color.color_f2a649))holder.setBackgroundResource(R.id.tv_admin, R.drawable.bg_1af2a649_2radius)}3 -> {holder.setText(R.id.tv_admin, "成员")holder.setTextColor(R.id.tv_admin,AppContext.appContext.resources.getColor(R.color.font_39ba81))holder.setBackgroundResource(R.id.tv_admin, R.drawable.bg_39ba81_2radius)}}var tvTop = holder.getView<TextView>(R.id.tv_top)tvTop.text = if (item.topFlag) {"取消置顶"} else {"置顶"}if (item.topFlag) {holder.setBackgroundColor(R.id.ll_top,AppContext.appContext.resources.getColor(R.color.color_ff615d))} else {holder.setBackgroundColor(R.id.ll_top,AppContext.appContext.resources.getColor(R.color.font_c9cdd4))}}
}

第三步:代码

mTeamAdapter.addChildClickViewIds(R.id.tv_top, R.id.cst_out)
mTeamAdapter.setOnItemChildClickListener { adapter, view, position ->val bean = adapter.data[position] as TeamListBeanwhen (view.id) {R.id.tv_top -> {bean.topFlag = !bean.topFlagadapter.notification}R.id.cst_out -> {}}}

http://www.lryc.cn/news/119629.html

相关文章:

  • Pycharm解决启动时候索引慢的问题
  • Http请求响应时间一般划分标准
  • 生成测试报告,在Unittest框架中就是简单
  • 生成式人工智能的潜在有害影响与未来之路(一)
  • lightdb23.3 表名与包名不能重复
  • Oracle 开发篇+Java通过HiKariCP访问Oracle数据库
  • 进销存管理系统(小杨国贸)springboot采购仓库财务java jsp源代码mysql
  • 指针初阶(2)
  • 基于Gradio的GPT聊天程序
  • 包管理工具详解npm 、 yarn 、 cnpm 、 npx 、 pnpm(2023)
  • Terraform 系列-批量创建资源时如何根据某个字段判断是否创建
  • Android侧滑栏(一)可缩放可一起移动的侧滑栏
  • 简单程度与自负是否相关?探索STM32的学习价值
  • 第二章:CSS基础进阶-part3:弹性例子布局
  • 函数与方法有区别?
  • VMware vCenter忘记密码操作,和Linus原理一致
  • Bert详细学习及代码实现详解
  • Vue [Day7] 综合案例
  • 基于R做宏基因组的进化树ClusterTree分析
  • 栈和队列修炼指南(基本操作+OJ练习)
  • 伪类和伪元素有何区别?
  • 自动测试框架airtest应用一:将XX读书书籍保存为PDF
  • ValueError:The following settings are not supported :{‘username‘: ‘neo4j“}
  • 360安全卫士右下角广告弹窗太多怎么彻底关闭?
  • 链表有无环以及确定入环口详解
  • chrome插件开发实例08- 使用Vue.js开发chrome插件
  • PCL 计算外接圆的半径
  • Matlab实现神经网络SOM算法(附上完整仿真源码)
  • 【遍历】非递归法 二叉树的前中后序遍历
  • Python将tiff转换成png