Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – Does View Binding support view binding for Adapter classes

Posted on November 11, 2022 By

Solution 1 :

enter code here

val view = BistItemParentSidemenuBinding
.inflate(LayoutInflater.from(parent.context),
parent, false).root

This above should work instead of

var convertView: View? = convertView
?: return context.layoutInflater.inflate(R.layout.list_item_child_sidemenu, null)

Problem :

I have just updated Android Studio to 3.6 and enabled View Binding in my project and I can use View Binding in my Fragments.

I have ListItemAdapter class which subclass from BaseExpandableListAdapter and I want to use View Binding for this class also. It seems it is not supported for Adapter Classes ?

As I mentioned above. I am using ExpandableListView. Below is code for inflating GroupView and ChildView inside expandableListView Adapter Class.

For now I am using KotlinX.android.synthetic

override fun getGroupView(
    groupPosition: Int,
    isExpanded: Boolean,
    convertView: View?,
    parent: ViewGroup?
): View {
    var convertView: View? = convertView
        ?: return context.layoutInflater.inflate(R.layout.list_item_parent_sidemenu, null)
    convertView!!.imgGroupIndicatorIcon.isSelected = isExpanded
    var headerTitle = getGroup(groupPosition) as String
    convertView!!.txtSideMenuParent.text = headerTitle
    return convertView!!
}


override fun getChildView(
    groupPosition: Int,
    childPosition: Int,
    isLastChild: Boolean,
    convertView: View?,
    parent: ViewGroup?
): View {
    var convertView: View? = convertView
        ?: return context.layoutInflater.inflate(R.layout.list_item_child_sidemenu, null)
    var childText = getChild(groupPosition, childPosition) as String
    convertView!!.txtSideMenuChild.text = childText
    return convertView!!
}

Comments

Comment posted by question

i think you can find your answer in this

Comment posted by minimal reproducible example

Please provide a

Comment posted by CommonsWare

Off the cuff, you should be able to use view binding in both of those functions, to replace your existing

READ  [FIXED] java - How can I get the random images displaying to not repeat?
Powered by Inline Related Posts
Android Tags:android, android-layout, binding, view

Post navigation

Previous Post: [FIXED] android – how to change notification background color in nougat?
Next Post: [FIXED] android – How to make width ratio equal in XML GridView

Related Posts

[FIXED] Can we use equivalent of SF Symbol on Android device in flutter project? Android
[FIXED] java – How do I disable persistence (caching) for firestore on Android Android
[FIXED] android – How to i get textview from inside recyclerview Android
[FIXED] java – Android fragment lifecycle issue Android
[FIXED] java – Keeping an account logged in an Android app Android
[FIXED] java – ArrayList add() sometimes does not add element obtained from Firebase to ArrayList Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is a good substitute for condensed milk?
  • ¿Como el cuerpo te avisa cuando te va a dar un infarto?
  • What is the luxury brand of Jaguar?
  • Who is Big poppa baseball player?
  • What material are foam runners?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme