Предметы утилизатора такие:
что мне нужно, и я не могу понять, как это: Когда кто-то нажимает кнопку , новый идентичный макет, чем предыдущий, появляется под уже существующим (только для элемента, который был нажат). Я создал ресурс макета, идентичный линейному макету в представлении рециркулятора, который должен дублироваться.
Мне нужно несколько таких, а не один, поэтому я не могу просто разместить макет ниже и сделать видимость недоступной. это.
Вот мой адаптер:
class SpentCardAdapter(var welcomeViewModel: WelcomeViewModel, var resource: Int): RecyclerView.Adapter<SpentCardAdapter.SpentCardHolder>(){
var spentCards: List<RecyclerViewSpentItems>? = null
fun setCardsList(spentCard: List<RecyclerViewSpentItems>?){
this.spentCards = spentCard
}
override fun getItemCount(): Int {
return spentCards?.size ?: 0
}
override fun onBindViewHolder(holder: SpentCardHolder, position: Int) {
holder.setDataCard(welcomeViewModel, position)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SpentCardHolder {
val layoutInflater: LayoutInflater = LayoutInflater.from(parent.context)
val binding:ViewDataBinding = DataBindingUtil.inflate(layoutInflater, viewType, parent, false)
return SpentCardHolder(binding)
}
override fun getItemViewType(position: Int): Int {
return getLayoutIdForPosition(position)
}
fun getLayoutIdForPosition(position: Int): Int{
return resource
}
class SpentCardHolder(binding: ViewDataBinding):RecyclerView.ViewHolder(binding.root){
private var binding: ViewDataBinding? = null
init {
this.binding = binding
}
fun setDataCard(welcomeViewModel: WelcomeViewModel, position: Int){
binding?.setVariable(BR.model, welcomeViewModel)
binding?.setVariable(BR.position, position)
binding?.executePendingBindings()
}
}
}
Пожалуйста, помогите мне Android Мастера, вы моя единственная надежда!