viewGroup return null en el adaptador Recyclerview

Intento agregar una list con Recyclerview en mi fragment. pero obtengo un error en mi adaptador cuando el adaptador intenta inflar el layout. y me parece que viewGroup es nulo. He tenido éxito la última vez, pero uso Recyclerview en actividad no en fragment. No sé dónde está mi error. aquí mi post de error

android.view.InflateException: Binary XML file line #0: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference at android.view.LayoutInflater.inflate(LayoutInflater.java:543) at android.view.LayoutInflater.inflate(LayoutInflater.java:427) at android.databinding.DataBindingUtil.inflate(DataBindingUtil.java:116) at android.databinding.DataBindingUtil.inflate(DataBindingUtil.java:88) at com.unicorn.muf.mockup.feature.tracking.adapter.TrackingAdapter.onCreateViewHolder(TrackingAdapter.kt:21) at com.unicorn.muf.mockup.feature.tracking.adapter.TrackingAdapter.onCreateViewHolder(TrackingAdapter.kt:15) at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6493) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5680) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5563) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5559) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2229) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1556) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1516) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:608) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3693) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3410) at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3962) at android.view.View.layout(View.java:16952) 

y aquí mi fragment

 class TrackingFragment : Fragment(), TrackingAdapter.onItemClick { private val TAG = "TrackingFragment" private lateinit var binding : FragmentTrackingBinding private var list = ArrayList<TrackingModel>() private var adapter : TrackingAdapter? = null override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { binding = DataBindingUtil.inflate(inflater,R.layout.fragment_tracking,container,false) binding.vRecyclerview.layoutManager = LinearLayoutManager(context) binding.vRecyclerview.itemAnimator = DefaultItemAnimator() adapter = TrackingAdapter(list,context) adapter!!.setOnClick(this) binding.vRecyclerview.adapter = adapter initdummydata() return binding.root } override fun onClickItem(model: TrackingModel) { val gson = Gson() val intent = Intent(context,DetailTrackingActivity::class.java) intent.putExtra(Constants.KEY_GSON, gson.toJson(model)) startActivity(intent) } private fun initdummydata(){ Log.d(TAG, "initData") list.add(TrackingModel("WO",5000000,"Karyawan","Parji", "xxxxxasdax", "BA 1234 BA", "Truck", "Asus", "Jakarta", "A4X", "1234", "12334")) list.add(TrackingModel("WO",40000,"Karyawan","Parjo", "xxxxxasdax", "BA 1234 BA", "Truck", "Asus", "Jakarta", "A4X", "1234", "12334")) list.add(TrackingModel("WO",5000000,"Karyawan","Parje", "xxxxxasdax", "BA 1234 BA", "Truck", "Asus", "Jakarta", "A4X", "1234", "12334")) list.add(TrackingModel("WO",1230000,"Karyawan","Parjer", "xxxxxasdax", "BA 1234 BA", "Truck", "Asus", "Jakarta", "A4X", "1234", "12334")) list.add(TrackingModel("WO",900000,"Karyawan","Parjip", "xxxxxasdax", "BA 1234 BA", "Truck", "Asus", "Jakarta", "A4X", "1234", "12334")) list.add(TrackingModel("WO",1000000000,"Karyawan","Parjan", "xxxxxasdax", "BA 1234 BA", "Truck", "Asus", "Jakarta", "A4X", "1234", "12334")) list.add(TrackingModel("WO",5000000,"Karyawan","Parjak", "xxxxxasdax", "BA 1234 BA", "Truck", "Asus", "Jakarta", "A4X", "1234", "12334")) adapter!!.notifyDataSetChanged() } companion object { fun newInstance(): TrackingFragment = TrackingFragment() } 

aquí mi adaptador.

 class TrackingAdapter(var list: MutableList<TrackingModel>, var context: Context) : RecyclerView.Adapter<TrackingAdapter.viewHolder>() { private var onclick : onItemClick? = null override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): viewHolder { val binding : ItemTrackingDataBinding = DataBindingUtil.inflate( LayoutInflater.from(context),R.layout.item_tracking_data,parent,false) return viewHolder(binding) } override fun onBindViewHolder(holder: viewHolder?, position: Int) { val model = list[position] holder!!.bind(model) } override fun getItemCount(): Int = list.size inner class viewHolder(private var binding: ItemTrackingDataBinding) : RecyclerView.ViewHolder(binding.root){ init { binding.vLayoutTracking.setOnClickListener({ val position = adapterPosition onclick!!.onClickItem(list[position]) }) } fun bind(model: TrackingModel){ binding.vName.text = model.nama binding.vNoapp.text = model.no_kontrak binding.vNomsn.text = model.no_mesin binding.vNopol.text = model.no_polisi binding.vStatus.text = model.status binding.executePendingBindings() } } fun setOnClick (onItemClick: onItemClick){ this.onclick = onItemClick } interface onItemClick{ fun onClickItem(model: TrackingModel) } 

Recibo un error en onCreateviewHolder aquí.

 override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): viewHolder { val binding : ItemTrackingDataBinding = DataBindingUtil.inflate( LayoutInflater.from(context),R.layout.item_tracking_data,parent,false) return viewHolder(binding) } 

He rastreado el padre es nulo. o hay algún error mío apreciaré mucho si alguien me ayuda.

intente replace el método onCreateViewHolder () con esto:

override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): viewHolder = viewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_tracking_data,parent,false))

Por favor intente esto:

 override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): viewHolder { val binding : ItemTrackingDataBinding = DataBindingUtil.inflate( LayoutInflater.from(parent.getContext()),R.layout.item_tracking_data,parent,false) return viewHolder(binding) } 

y avíseme si esto ayudó.

Esto es muy divertido, me paso casi todo el día para resolver esto .. mi error está en mi xml personalizado, uso view como este.

 <view android:background="@color/colorGray" android:layout_width="match_parent" android:layout_height="1dp"/> 

nada de error, pero su vista falsa … la correcta es

 <View android:background="@color/colorGray" android:layout_width="match_parent" android:layout_height="1dp"/> 

Espero que esto ayude a alguien.