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