【问题标题】:is there a solution for accessing the first item in a recyclerView是否有访问 recyclerView 中第一项的解决方案
【发布时间】:2021-01-09 06:40:00
【问题描述】:

我正在创建用户指南,我想在用户指南中描述的项目之一在我的回收站中 请查看帮助我 我正在使用这个库:com.github.mreram:showcaseview:1.2.0

找到解决方案:

private var isPlayed = false
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
    holder.onFill(holder.adapterPosition)
    if (position == 0 && !isPlayed) {
        holder.guide()
        isPlayed = false
    }
}

【问题讨论】:

  • 请更新您的问题并包含您已经尝试过的代码。

标签: java android kotlin showcaseview user-guide


【解决方案1】:

你可以通过在onBindview方法中检查item的位置来访问recyclerview的第一个item

   public void onBindViewHolder(ViewHolder holder, int position) {

    if(position==0)
     // write your code here
    else
     // other code
   }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-13
    • 2011-03-10
    相关资源
    最近更新 更多