Android Kotlin. Troubles with databinding to recyclerview using fragments











up vote
0
down vote

favorite












I'm trying to learn how to implement databinding in an Android app. I have a small app I'm working with to learn this. And while I have databinding working for part of the app. I have hit a hiccup when trying to implement a recyclerview. I just cannot seem to get it. Been banging away at it for two or three days, and getting frustrated. Thought I'd ask you guys.



The app is super simple at this point.



The part i'm stuck on is accessing my recyclerview from an .xml layout from my MainFragment.kt



At first I was trying to use binding, but got frustrated and went back to just trying to use findViewById, but that is giving me issue too. I am beginning to think, I don't have as firm a grasp on databinding as I thought I did.



This is from the fragment that holds the recyclerView:



fragment_main.xml



<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
android:id="@+id/job_recyclerView"/>


I have another small layout file that is using Cardview to show each individual item in the recyclerview



A super simple Model:



JobData.kt



data class JobData(val companyName: String, val location: String)


An Adapter:



JobAdapter.kt



class CustomAdapter(val userList: ArrayList<JobData>) : RecyclerView.Adapter<CustomAdapter.ViewHolder>() {

//Returning view for each item in the list
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomAdapter.ViewHolder {
val v = LayoutInflater.from(parent.context).inflate(R.layout.job_item_layout, parent, false)
return ViewHolder(v)
}

//Binding the data on the list
override fun onBindViewHolder(holder: CustomAdapter.ViewHolder, position: Int) {
holder.bindItems(userList[position])
}

override fun getItemCount(): Int {
return userList.size
}

//Class holds the job list view
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

fun bindItems(job: JobData) {
val textViewName = itemView.findViewById(R.id.tv_company_name) as TextView
val textViewAddress = itemView.findViewById(R.id.tv_Location) as TextView
textViewName.text = job.companyName
textViewAddress.text = job.location
}
}
}


And then the code in my MainFragment to handle it all, which it is not doing. I've tried everything, it was getting ugly. As you can see below. Binding is in place and working for my FloatingActionButton. But I for some reason cannot figure out how to access that recylerview. At the point the code is at below, I thought I'd just accessing using findViewById, but that is not working either.



MainFragment.kt
class MainFragment : Fragment() {



override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val binding: FragmentMainBinding = DataBindingUtil.inflate(
inflater, R.layout.fragment_main, container, false)

//Setting onClickListener for FAB(floating action button) using Navigation
binding.createNewJobFAB.setOnClickListener { v: View ->
v.findNavController().navigate(R.id.action_mainFragment_to_createNewJobFragment)
}

//getting recyclerview from xml
val recyclerView = findViewById(R.id.job_recyclerView) as RecyclerView

//adding a layoutmanager
recyclerView.layoutManager = LinearLayoutManager(this, RecyclerView.VERTICAL, false)


//Arraylist to store jobs using the data class JobData
val jobs = ArrayList<JobData>()

//add dummy data to list
jobs.add(JobData("A Company", "Town A"))
jobs.add(JobData("B Company", "Town B"))
jobs.add(JobData("C Company", "Town C"))
jobs.add(JobData("D Company", "Town D"))

//creating adapter
val adapter = CustomAdapter(jobs)

//add adapter to recyclerView
recyclerView.adapter = adapter
return binding.root
}
}


The above fails to compile for two reasons:




  1. findViewById shows as an "Unresolved Reference".

  2. When adding the layoutManager, "this" shows as a "Type Mismatch"


Which I believe is due to the fact that Fragments do not have a context. Or so, I think anyway. But I don't know to resolve that? Maybe override some other method, but I can't seem to figure out which or how?



Oh and MainActivity looks like:



MainActivity.kt



class MainActivity : AppCompatActivity() {

//private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@Suppress("UNUSED_VARIABLE")
val binding = DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main)
}

//Ensures back button works as it should
override fun onSupportNavigateUp() = findNavController(this, R.id.navHostFragment).navigateUp()
}


Which is pointing to Nav_Graph for Android Navigation (part of JetPack). This bit is fine and working.



Adding gradle files to show that my dependencies were set correctly as suggested below.



app/gradle



android {
compileSdkVersion 28
dataBinding {
enabled = true
}
...
}

kapt {
generateStubs = true
correctErrorTypes = true
}

dependencies {
...
kapt "com.android.databinding:compiler:$gradle_version"

...
}









share|improve this question
























  • To make findViewById() and LinearLayout constructor work use Fragment#getContext(). To solve problem with databinding, ensure please, that you have apply plugin: 'kotlin-kapt' in app/build.gradle and kapt "com.android.databinding:compiler:version" in dependencies section of app/build.gradle
    – ConstOrVar
    Nov 18 at 8:31












  • Sorry, I forgot to show or mention my dependencies. Those are all set. I will edit main post to show that info. I will looki n into using Fragment#getContext() if I cannot get binding to work.
    – CB Midkiff
    Nov 18 at 8:41












  • Have you already solved that problem?
    – ConstOrVar
    Nov 18 at 12:44










  • No still working on it.
    – CB Midkiff
    Nov 19 at 8:31










  • What is valuf of $gradle_version?
    – ConstOrVar
    Nov 19 at 9:23















up vote
0
down vote

favorite












I'm trying to learn how to implement databinding in an Android app. I have a small app I'm working with to learn this. And while I have databinding working for part of the app. I have hit a hiccup when trying to implement a recyclerview. I just cannot seem to get it. Been banging away at it for two or three days, and getting frustrated. Thought I'd ask you guys.



The app is super simple at this point.



The part i'm stuck on is accessing my recyclerview from an .xml layout from my MainFragment.kt



At first I was trying to use binding, but got frustrated and went back to just trying to use findViewById, but that is giving me issue too. I am beginning to think, I don't have as firm a grasp on databinding as I thought I did.



This is from the fragment that holds the recyclerView:



fragment_main.xml



<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
android:id="@+id/job_recyclerView"/>


I have another small layout file that is using Cardview to show each individual item in the recyclerview



A super simple Model:



JobData.kt



data class JobData(val companyName: String, val location: String)


An Adapter:



JobAdapter.kt



class CustomAdapter(val userList: ArrayList<JobData>) : RecyclerView.Adapter<CustomAdapter.ViewHolder>() {

//Returning view for each item in the list
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomAdapter.ViewHolder {
val v = LayoutInflater.from(parent.context).inflate(R.layout.job_item_layout, parent, false)
return ViewHolder(v)
}

//Binding the data on the list
override fun onBindViewHolder(holder: CustomAdapter.ViewHolder, position: Int) {
holder.bindItems(userList[position])
}

override fun getItemCount(): Int {
return userList.size
}

//Class holds the job list view
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

fun bindItems(job: JobData) {
val textViewName = itemView.findViewById(R.id.tv_company_name) as TextView
val textViewAddress = itemView.findViewById(R.id.tv_Location) as TextView
textViewName.text = job.companyName
textViewAddress.text = job.location
}
}
}


And then the code in my MainFragment to handle it all, which it is not doing. I've tried everything, it was getting ugly. As you can see below. Binding is in place and working for my FloatingActionButton. But I for some reason cannot figure out how to access that recylerview. At the point the code is at below, I thought I'd just accessing using findViewById, but that is not working either.



MainFragment.kt
class MainFragment : Fragment() {



override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val binding: FragmentMainBinding = DataBindingUtil.inflate(
inflater, R.layout.fragment_main, container, false)

//Setting onClickListener for FAB(floating action button) using Navigation
binding.createNewJobFAB.setOnClickListener { v: View ->
v.findNavController().navigate(R.id.action_mainFragment_to_createNewJobFragment)
}

//getting recyclerview from xml
val recyclerView = findViewById(R.id.job_recyclerView) as RecyclerView

//adding a layoutmanager
recyclerView.layoutManager = LinearLayoutManager(this, RecyclerView.VERTICAL, false)


//Arraylist to store jobs using the data class JobData
val jobs = ArrayList<JobData>()

//add dummy data to list
jobs.add(JobData("A Company", "Town A"))
jobs.add(JobData("B Company", "Town B"))
jobs.add(JobData("C Company", "Town C"))
jobs.add(JobData("D Company", "Town D"))

//creating adapter
val adapter = CustomAdapter(jobs)

//add adapter to recyclerView
recyclerView.adapter = adapter
return binding.root
}
}


The above fails to compile for two reasons:




  1. findViewById shows as an "Unresolved Reference".

  2. When adding the layoutManager, "this" shows as a "Type Mismatch"


Which I believe is due to the fact that Fragments do not have a context. Or so, I think anyway. But I don't know to resolve that? Maybe override some other method, but I can't seem to figure out which or how?



Oh and MainActivity looks like:



MainActivity.kt



class MainActivity : AppCompatActivity() {

//private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@Suppress("UNUSED_VARIABLE")
val binding = DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main)
}

//Ensures back button works as it should
override fun onSupportNavigateUp() = findNavController(this, R.id.navHostFragment).navigateUp()
}


Which is pointing to Nav_Graph for Android Navigation (part of JetPack). This bit is fine and working.



Adding gradle files to show that my dependencies were set correctly as suggested below.



app/gradle



android {
compileSdkVersion 28
dataBinding {
enabled = true
}
...
}

kapt {
generateStubs = true
correctErrorTypes = true
}

dependencies {
...
kapt "com.android.databinding:compiler:$gradle_version"

...
}









share|improve this question
























  • To make findViewById() and LinearLayout constructor work use Fragment#getContext(). To solve problem with databinding, ensure please, that you have apply plugin: 'kotlin-kapt' in app/build.gradle and kapt "com.android.databinding:compiler:version" in dependencies section of app/build.gradle
    – ConstOrVar
    Nov 18 at 8:31












  • Sorry, I forgot to show or mention my dependencies. Those are all set. I will edit main post to show that info. I will looki n into using Fragment#getContext() if I cannot get binding to work.
    – CB Midkiff
    Nov 18 at 8:41












  • Have you already solved that problem?
    – ConstOrVar
    Nov 18 at 12:44










  • No still working on it.
    – CB Midkiff
    Nov 19 at 8:31










  • What is valuf of $gradle_version?
    – ConstOrVar
    Nov 19 at 9:23













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to learn how to implement databinding in an Android app. I have a small app I'm working with to learn this. And while I have databinding working for part of the app. I have hit a hiccup when trying to implement a recyclerview. I just cannot seem to get it. Been banging away at it for two or three days, and getting frustrated. Thought I'd ask you guys.



The app is super simple at this point.



The part i'm stuck on is accessing my recyclerview from an .xml layout from my MainFragment.kt



At first I was trying to use binding, but got frustrated and went back to just trying to use findViewById, but that is giving me issue too. I am beginning to think, I don't have as firm a grasp on databinding as I thought I did.



This is from the fragment that holds the recyclerView:



fragment_main.xml



<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
android:id="@+id/job_recyclerView"/>


I have another small layout file that is using Cardview to show each individual item in the recyclerview



A super simple Model:



JobData.kt



data class JobData(val companyName: String, val location: String)


An Adapter:



JobAdapter.kt



class CustomAdapter(val userList: ArrayList<JobData>) : RecyclerView.Adapter<CustomAdapter.ViewHolder>() {

//Returning view for each item in the list
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomAdapter.ViewHolder {
val v = LayoutInflater.from(parent.context).inflate(R.layout.job_item_layout, parent, false)
return ViewHolder(v)
}

//Binding the data on the list
override fun onBindViewHolder(holder: CustomAdapter.ViewHolder, position: Int) {
holder.bindItems(userList[position])
}

override fun getItemCount(): Int {
return userList.size
}

//Class holds the job list view
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

fun bindItems(job: JobData) {
val textViewName = itemView.findViewById(R.id.tv_company_name) as TextView
val textViewAddress = itemView.findViewById(R.id.tv_Location) as TextView
textViewName.text = job.companyName
textViewAddress.text = job.location
}
}
}


And then the code in my MainFragment to handle it all, which it is not doing. I've tried everything, it was getting ugly. As you can see below. Binding is in place and working for my FloatingActionButton. But I for some reason cannot figure out how to access that recylerview. At the point the code is at below, I thought I'd just accessing using findViewById, but that is not working either.



MainFragment.kt
class MainFragment : Fragment() {



override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val binding: FragmentMainBinding = DataBindingUtil.inflate(
inflater, R.layout.fragment_main, container, false)

//Setting onClickListener for FAB(floating action button) using Navigation
binding.createNewJobFAB.setOnClickListener { v: View ->
v.findNavController().navigate(R.id.action_mainFragment_to_createNewJobFragment)
}

//getting recyclerview from xml
val recyclerView = findViewById(R.id.job_recyclerView) as RecyclerView

//adding a layoutmanager
recyclerView.layoutManager = LinearLayoutManager(this, RecyclerView.VERTICAL, false)


//Arraylist to store jobs using the data class JobData
val jobs = ArrayList<JobData>()

//add dummy data to list
jobs.add(JobData("A Company", "Town A"))
jobs.add(JobData("B Company", "Town B"))
jobs.add(JobData("C Company", "Town C"))
jobs.add(JobData("D Company", "Town D"))

//creating adapter
val adapter = CustomAdapter(jobs)

//add adapter to recyclerView
recyclerView.adapter = adapter
return binding.root
}
}


The above fails to compile for two reasons:




  1. findViewById shows as an "Unresolved Reference".

  2. When adding the layoutManager, "this" shows as a "Type Mismatch"


Which I believe is due to the fact that Fragments do not have a context. Or so, I think anyway. But I don't know to resolve that? Maybe override some other method, but I can't seem to figure out which or how?



Oh and MainActivity looks like:



MainActivity.kt



class MainActivity : AppCompatActivity() {

//private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@Suppress("UNUSED_VARIABLE")
val binding = DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main)
}

//Ensures back button works as it should
override fun onSupportNavigateUp() = findNavController(this, R.id.navHostFragment).navigateUp()
}


Which is pointing to Nav_Graph for Android Navigation (part of JetPack). This bit is fine and working.



Adding gradle files to show that my dependencies were set correctly as suggested below.



app/gradle



android {
compileSdkVersion 28
dataBinding {
enabled = true
}
...
}

kapt {
generateStubs = true
correctErrorTypes = true
}

dependencies {
...
kapt "com.android.databinding:compiler:$gradle_version"

...
}









share|improve this question















I'm trying to learn how to implement databinding in an Android app. I have a small app I'm working with to learn this. And while I have databinding working for part of the app. I have hit a hiccup when trying to implement a recyclerview. I just cannot seem to get it. Been banging away at it for two or three days, and getting frustrated. Thought I'd ask you guys.



The app is super simple at this point.



The part i'm stuck on is accessing my recyclerview from an .xml layout from my MainFragment.kt



At first I was trying to use binding, but got frustrated and went back to just trying to use findViewById, but that is giving me issue too. I am beginning to think, I don't have as firm a grasp on databinding as I thought I did.



This is from the fragment that holds the recyclerView:



fragment_main.xml



<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
android:id="@+id/job_recyclerView"/>


I have another small layout file that is using Cardview to show each individual item in the recyclerview



A super simple Model:



JobData.kt



data class JobData(val companyName: String, val location: String)


An Adapter:



JobAdapter.kt



class CustomAdapter(val userList: ArrayList<JobData>) : RecyclerView.Adapter<CustomAdapter.ViewHolder>() {

//Returning view for each item in the list
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomAdapter.ViewHolder {
val v = LayoutInflater.from(parent.context).inflate(R.layout.job_item_layout, parent, false)
return ViewHolder(v)
}

//Binding the data on the list
override fun onBindViewHolder(holder: CustomAdapter.ViewHolder, position: Int) {
holder.bindItems(userList[position])
}

override fun getItemCount(): Int {
return userList.size
}

//Class holds the job list view
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

fun bindItems(job: JobData) {
val textViewName = itemView.findViewById(R.id.tv_company_name) as TextView
val textViewAddress = itemView.findViewById(R.id.tv_Location) as TextView
textViewName.text = job.companyName
textViewAddress.text = job.location
}
}
}


And then the code in my MainFragment to handle it all, which it is not doing. I've tried everything, it was getting ugly. As you can see below. Binding is in place and working for my FloatingActionButton. But I for some reason cannot figure out how to access that recylerview. At the point the code is at below, I thought I'd just accessing using findViewById, but that is not working either.



MainFragment.kt
class MainFragment : Fragment() {



override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val binding: FragmentMainBinding = DataBindingUtil.inflate(
inflater, R.layout.fragment_main, container, false)

//Setting onClickListener for FAB(floating action button) using Navigation
binding.createNewJobFAB.setOnClickListener { v: View ->
v.findNavController().navigate(R.id.action_mainFragment_to_createNewJobFragment)
}

//getting recyclerview from xml
val recyclerView = findViewById(R.id.job_recyclerView) as RecyclerView

//adding a layoutmanager
recyclerView.layoutManager = LinearLayoutManager(this, RecyclerView.VERTICAL, false)


//Arraylist to store jobs using the data class JobData
val jobs = ArrayList<JobData>()

//add dummy data to list
jobs.add(JobData("A Company", "Town A"))
jobs.add(JobData("B Company", "Town B"))
jobs.add(JobData("C Company", "Town C"))
jobs.add(JobData("D Company", "Town D"))

//creating adapter
val adapter = CustomAdapter(jobs)

//add adapter to recyclerView
recyclerView.adapter = adapter
return binding.root
}
}


The above fails to compile for two reasons:




  1. findViewById shows as an "Unresolved Reference".

  2. When adding the layoutManager, "this" shows as a "Type Mismatch"


Which I believe is due to the fact that Fragments do not have a context. Or so, I think anyway. But I don't know to resolve that? Maybe override some other method, but I can't seem to figure out which or how?



Oh and MainActivity looks like:



MainActivity.kt



class MainActivity : AppCompatActivity() {

//private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@Suppress("UNUSED_VARIABLE")
val binding = DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main)
}

//Ensures back button works as it should
override fun onSupportNavigateUp() = findNavController(this, R.id.navHostFragment).navigateUp()
}


Which is pointing to Nav_Graph for Android Navigation (part of JetPack). This bit is fine and working.



Adding gradle files to show that my dependencies were set correctly as suggested below.



app/gradle



android {
compileSdkVersion 28
dataBinding {
enabled = true
}
...
}

kapt {
generateStubs = true
correctErrorTypes = true
}

dependencies {
...
kapt "com.android.databinding:compiler:$gradle_version"

...
}






android android-fragments android-recyclerview kotlin android-databinding






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 at 8:49

























asked Nov 18 at 8:15









CB Midkiff

124




124












  • To make findViewById() and LinearLayout constructor work use Fragment#getContext(). To solve problem with databinding, ensure please, that you have apply plugin: 'kotlin-kapt' in app/build.gradle and kapt "com.android.databinding:compiler:version" in dependencies section of app/build.gradle
    – ConstOrVar
    Nov 18 at 8:31












  • Sorry, I forgot to show or mention my dependencies. Those are all set. I will edit main post to show that info. I will looki n into using Fragment#getContext() if I cannot get binding to work.
    – CB Midkiff
    Nov 18 at 8:41












  • Have you already solved that problem?
    – ConstOrVar
    Nov 18 at 12:44










  • No still working on it.
    – CB Midkiff
    Nov 19 at 8:31










  • What is valuf of $gradle_version?
    – ConstOrVar
    Nov 19 at 9:23


















  • To make findViewById() and LinearLayout constructor work use Fragment#getContext(). To solve problem with databinding, ensure please, that you have apply plugin: 'kotlin-kapt' in app/build.gradle and kapt "com.android.databinding:compiler:version" in dependencies section of app/build.gradle
    – ConstOrVar
    Nov 18 at 8:31












  • Sorry, I forgot to show or mention my dependencies. Those are all set. I will edit main post to show that info. I will looki n into using Fragment#getContext() if I cannot get binding to work.
    – CB Midkiff
    Nov 18 at 8:41












  • Have you already solved that problem?
    – ConstOrVar
    Nov 18 at 12:44










  • No still working on it.
    – CB Midkiff
    Nov 19 at 8:31










  • What is valuf of $gradle_version?
    – ConstOrVar
    Nov 19 at 9:23
















To make findViewById() and LinearLayout constructor work use Fragment#getContext(). To solve problem with databinding, ensure please, that you have apply plugin: 'kotlin-kapt' in app/build.gradle and kapt "com.android.databinding:compiler:version" in dependencies section of app/build.gradle
– ConstOrVar
Nov 18 at 8:31






To make findViewById() and LinearLayout constructor work use Fragment#getContext(). To solve problem with databinding, ensure please, that you have apply plugin: 'kotlin-kapt' in app/build.gradle and kapt "com.android.databinding:compiler:version" in dependencies section of app/build.gradle
– ConstOrVar
Nov 18 at 8:31














Sorry, I forgot to show or mention my dependencies. Those are all set. I will edit main post to show that info. I will looki n into using Fragment#getContext() if I cannot get binding to work.
– CB Midkiff
Nov 18 at 8:41






Sorry, I forgot to show or mention my dependencies. Those are all set. I will edit main post to show that info. I will looki n into using Fragment#getContext() if I cannot get binding to work.
– CB Midkiff
Nov 18 at 8:41














Have you already solved that problem?
– ConstOrVar
Nov 18 at 12:44




Have you already solved that problem?
– ConstOrVar
Nov 18 at 12:44












No still working on it.
– CB Midkiff
Nov 19 at 8:31




No still working on it.
– CB Midkiff
Nov 19 at 8:31












What is valuf of $gradle_version?
– ConstOrVar
Nov 19 at 9:23




What is valuf of $gradle_version?
– ConstOrVar
Nov 19 at 9:23












3 Answers
3






active

oldest

votes

















up vote
0
down vote



accepted










Encase your xml in <layout>..<layout/>



private lateinit var binding: FragmentXXXBinding

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = FragmentXXXBinding.inflate(inflater)
return binding.root
}


Then you can call recyclerview by binding.jobRecyclerview



try to set all the click listeners etc on onViewCreated rather than onCreateView of fragment






share|improve this answer























  • Your example is how i'd like to do this. And is one of the ways I tried the other day. But for reason I cannot figure out just yet, it does not work. I have my .xml incased in <layout>..<layout/> and have just added the lateinit to FragmentMainBinding. But calling binding.job_recyclerView is where it fails. job_recyclerView remains as unresolved? This is where I am getting confused on binding.
    – CB Midkiff
    Nov 19 at 8:22












  • binding.jobRecyclerview it should be, does it not auto fill? I'd so a clean/rebuild project if it's not autofilling
    – Blue Jones
    Nov 19 at 8:43










  • Agreed. I have cleaned/rebuilt project and even restarted Android Studio. It does not like it.
    – CB Midkiff
    Nov 19 at 9:11










  • Can you please edit and post all xml, i've got a feeling it'll be something silly like a name wrong aha
    – Blue Jones
    Nov 19 at 9:27










  • Sorry, sorry. I fat fingered it. It is now seeing binding.jobRecyclerView.
    – CB Midkiff
    Nov 19 at 9:33


















up vote
0
down vote













It is wrong way to findViewById from Fragment(it is good technique for Activity):



val recyclerView = findViewById(R.id.job_recyclerView) as RecyclerView


First, fragment's layout have to be return by onCreateView() method.



override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_main, container, false)
}


I personally like do all fragment's business logic inside onViewCreated()



override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
//Now, we can use views by kotlinx
//val recyclerView = job_recyclerView
//Or old-fashioned way
val recyclerView = getView()!!.findViewById(R.id.job_recyclerView) as RecyclerView
}


RecylerView can be accessed from fragment's layout by having root view like: getView()!!.findViewById or by kotlinx inside onViewCreated(): job_recyclerView






share|improve this answer





















  • Sorry, your formatting is confusing to me? It seems like your suggesting using both 'onCreateView' and 'onViewCreated', or am I reading this wrong?
    – CB Midkiff
    Nov 19 at 9:05










  • Agree with koliczyna, onViewCreated() should handle the business logic, not oncreateView(), this should just be for inflating the layout
    – Blue Jones
    Nov 19 at 9:30










  • @CB Midkiff You are correct, I suggest to use both of them.
    – koliczyna
    Nov 20 at 8:53


















up vote
0
down vote













Ok, so first of all you are getting error on findViewById bcoz your fragment is unaware about the view that contains recyclerView



What you should do is, take an instance of view that you are inflating for this fragment ( declare view as a global variable, replace your inflater line with this. )



var rootView

// Inside onCreateView
var rootView = inflater?.inflate(R.layout.fragment, container, false)


Now replace, findViewById() with rootView.findViewById()



And the other error is bcoz the fragment does not have any context of it's own so replace this with activity!!



By writing activity!! you are calling getActicity() method which returns context of parent activity.






share|improve this answer





















  • I followed your suggestions and it did take care of the compiler errors, and the app now runs. The RecyclerView does not populate as it should. I does not show up at all. I think it is how that inflater is called. But I only had a little bit of time to work on it. I've been at the immigration offices all day dealing with Visa issues. Im going to work on it more this afternoon and tonight.
    – CB Midkiff
    Nov 19 at 8:06











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53359022%2fandroid-kotlin-troubles-with-databinding-to-recyclerview-using-fragments%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










Encase your xml in <layout>..<layout/>



private lateinit var binding: FragmentXXXBinding

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = FragmentXXXBinding.inflate(inflater)
return binding.root
}


Then you can call recyclerview by binding.jobRecyclerview



try to set all the click listeners etc on onViewCreated rather than onCreateView of fragment






share|improve this answer























  • Your example is how i'd like to do this. And is one of the ways I tried the other day. But for reason I cannot figure out just yet, it does not work. I have my .xml incased in <layout>..<layout/> and have just added the lateinit to FragmentMainBinding. But calling binding.job_recyclerView is where it fails. job_recyclerView remains as unresolved? This is where I am getting confused on binding.
    – CB Midkiff
    Nov 19 at 8:22












  • binding.jobRecyclerview it should be, does it not auto fill? I'd so a clean/rebuild project if it's not autofilling
    – Blue Jones
    Nov 19 at 8:43










  • Agreed. I have cleaned/rebuilt project and even restarted Android Studio. It does not like it.
    – CB Midkiff
    Nov 19 at 9:11










  • Can you please edit and post all xml, i've got a feeling it'll be something silly like a name wrong aha
    – Blue Jones
    Nov 19 at 9:27










  • Sorry, sorry. I fat fingered it. It is now seeing binding.jobRecyclerView.
    – CB Midkiff
    Nov 19 at 9:33















up vote
0
down vote



accepted










Encase your xml in <layout>..<layout/>



private lateinit var binding: FragmentXXXBinding

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = FragmentXXXBinding.inflate(inflater)
return binding.root
}


Then you can call recyclerview by binding.jobRecyclerview



try to set all the click listeners etc on onViewCreated rather than onCreateView of fragment






share|improve this answer























  • Your example is how i'd like to do this. And is one of the ways I tried the other day. But for reason I cannot figure out just yet, it does not work. I have my .xml incased in <layout>..<layout/> and have just added the lateinit to FragmentMainBinding. But calling binding.job_recyclerView is where it fails. job_recyclerView remains as unresolved? This is where I am getting confused on binding.
    – CB Midkiff
    Nov 19 at 8:22












  • binding.jobRecyclerview it should be, does it not auto fill? I'd so a clean/rebuild project if it's not autofilling
    – Blue Jones
    Nov 19 at 8:43










  • Agreed. I have cleaned/rebuilt project and even restarted Android Studio. It does not like it.
    – CB Midkiff
    Nov 19 at 9:11










  • Can you please edit and post all xml, i've got a feeling it'll be something silly like a name wrong aha
    – Blue Jones
    Nov 19 at 9:27










  • Sorry, sorry. I fat fingered it. It is now seeing binding.jobRecyclerView.
    – CB Midkiff
    Nov 19 at 9:33













up vote
0
down vote



accepted







up vote
0
down vote



accepted






Encase your xml in <layout>..<layout/>



private lateinit var binding: FragmentXXXBinding

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = FragmentXXXBinding.inflate(inflater)
return binding.root
}


Then you can call recyclerview by binding.jobRecyclerview



try to set all the click listeners etc on onViewCreated rather than onCreateView of fragment






share|improve this answer














Encase your xml in <layout>..<layout/>



private lateinit var binding: FragmentXXXBinding

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = FragmentXXXBinding.inflate(inflater)
return binding.root
}


Then you can call recyclerview by binding.jobRecyclerview



try to set all the click listeners etc on onViewCreated rather than onCreateView of fragment







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 18 at 14:15

























answered Nov 18 at 10:02









Blue Jones

1396




1396












  • Your example is how i'd like to do this. And is one of the ways I tried the other day. But for reason I cannot figure out just yet, it does not work. I have my .xml incased in <layout>..<layout/> and have just added the lateinit to FragmentMainBinding. But calling binding.job_recyclerView is where it fails. job_recyclerView remains as unresolved? This is where I am getting confused on binding.
    – CB Midkiff
    Nov 19 at 8:22












  • binding.jobRecyclerview it should be, does it not auto fill? I'd so a clean/rebuild project if it's not autofilling
    – Blue Jones
    Nov 19 at 8:43










  • Agreed. I have cleaned/rebuilt project and even restarted Android Studio. It does not like it.
    – CB Midkiff
    Nov 19 at 9:11










  • Can you please edit and post all xml, i've got a feeling it'll be something silly like a name wrong aha
    – Blue Jones
    Nov 19 at 9:27










  • Sorry, sorry. I fat fingered it. It is now seeing binding.jobRecyclerView.
    – CB Midkiff
    Nov 19 at 9:33


















  • Your example is how i'd like to do this. And is one of the ways I tried the other day. But for reason I cannot figure out just yet, it does not work. I have my .xml incased in <layout>..<layout/> and have just added the lateinit to FragmentMainBinding. But calling binding.job_recyclerView is where it fails. job_recyclerView remains as unresolved? This is where I am getting confused on binding.
    – CB Midkiff
    Nov 19 at 8:22












  • binding.jobRecyclerview it should be, does it not auto fill? I'd so a clean/rebuild project if it's not autofilling
    – Blue Jones
    Nov 19 at 8:43










  • Agreed. I have cleaned/rebuilt project and even restarted Android Studio. It does not like it.
    – CB Midkiff
    Nov 19 at 9:11










  • Can you please edit and post all xml, i've got a feeling it'll be something silly like a name wrong aha
    – Blue Jones
    Nov 19 at 9:27










  • Sorry, sorry. I fat fingered it. It is now seeing binding.jobRecyclerView.
    – CB Midkiff
    Nov 19 at 9:33
















Your example is how i'd like to do this. And is one of the ways I tried the other day. But for reason I cannot figure out just yet, it does not work. I have my .xml incased in <layout>..<layout/> and have just added the lateinit to FragmentMainBinding. But calling binding.job_recyclerView is where it fails. job_recyclerView remains as unresolved? This is where I am getting confused on binding.
– CB Midkiff
Nov 19 at 8:22






Your example is how i'd like to do this. And is one of the ways I tried the other day. But for reason I cannot figure out just yet, it does not work. I have my .xml incased in <layout>..<layout/> and have just added the lateinit to FragmentMainBinding. But calling binding.job_recyclerView is where it fails. job_recyclerView remains as unresolved? This is where I am getting confused on binding.
– CB Midkiff
Nov 19 at 8:22














binding.jobRecyclerview it should be, does it not auto fill? I'd so a clean/rebuild project if it's not autofilling
– Blue Jones
Nov 19 at 8:43




binding.jobRecyclerview it should be, does it not auto fill? I'd so a clean/rebuild project if it's not autofilling
– Blue Jones
Nov 19 at 8:43












Agreed. I have cleaned/rebuilt project and even restarted Android Studio. It does not like it.
– CB Midkiff
Nov 19 at 9:11




Agreed. I have cleaned/rebuilt project and even restarted Android Studio. It does not like it.
– CB Midkiff
Nov 19 at 9:11












Can you please edit and post all xml, i've got a feeling it'll be something silly like a name wrong aha
– Blue Jones
Nov 19 at 9:27




Can you please edit and post all xml, i've got a feeling it'll be something silly like a name wrong aha
– Blue Jones
Nov 19 at 9:27












Sorry, sorry. I fat fingered it. It is now seeing binding.jobRecyclerView.
– CB Midkiff
Nov 19 at 9:33




Sorry, sorry. I fat fingered it. It is now seeing binding.jobRecyclerView.
– CB Midkiff
Nov 19 at 9:33












up vote
0
down vote













It is wrong way to findViewById from Fragment(it is good technique for Activity):



val recyclerView = findViewById(R.id.job_recyclerView) as RecyclerView


First, fragment's layout have to be return by onCreateView() method.



override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_main, container, false)
}


I personally like do all fragment's business logic inside onViewCreated()



override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
//Now, we can use views by kotlinx
//val recyclerView = job_recyclerView
//Or old-fashioned way
val recyclerView = getView()!!.findViewById(R.id.job_recyclerView) as RecyclerView
}


RecylerView can be accessed from fragment's layout by having root view like: getView()!!.findViewById or by kotlinx inside onViewCreated(): job_recyclerView






share|improve this answer





















  • Sorry, your formatting is confusing to me? It seems like your suggesting using both 'onCreateView' and 'onViewCreated', or am I reading this wrong?
    – CB Midkiff
    Nov 19 at 9:05










  • Agree with koliczyna, onViewCreated() should handle the business logic, not oncreateView(), this should just be for inflating the layout
    – Blue Jones
    Nov 19 at 9:30










  • @CB Midkiff You are correct, I suggest to use both of them.
    – koliczyna
    Nov 20 at 8:53















up vote
0
down vote













It is wrong way to findViewById from Fragment(it is good technique for Activity):



val recyclerView = findViewById(R.id.job_recyclerView) as RecyclerView


First, fragment's layout have to be return by onCreateView() method.



override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_main, container, false)
}


I personally like do all fragment's business logic inside onViewCreated()



override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
//Now, we can use views by kotlinx
//val recyclerView = job_recyclerView
//Or old-fashioned way
val recyclerView = getView()!!.findViewById(R.id.job_recyclerView) as RecyclerView
}


RecylerView can be accessed from fragment's layout by having root view like: getView()!!.findViewById or by kotlinx inside onViewCreated(): job_recyclerView






share|improve this answer





















  • Sorry, your formatting is confusing to me? It seems like your suggesting using both 'onCreateView' and 'onViewCreated', or am I reading this wrong?
    – CB Midkiff
    Nov 19 at 9:05










  • Agree with koliczyna, onViewCreated() should handle the business logic, not oncreateView(), this should just be for inflating the layout
    – Blue Jones
    Nov 19 at 9:30










  • @CB Midkiff You are correct, I suggest to use both of them.
    – koliczyna
    Nov 20 at 8:53













up vote
0
down vote










up vote
0
down vote









It is wrong way to findViewById from Fragment(it is good technique for Activity):



val recyclerView = findViewById(R.id.job_recyclerView) as RecyclerView


First, fragment's layout have to be return by onCreateView() method.



override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_main, container, false)
}


I personally like do all fragment's business logic inside onViewCreated()



override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
//Now, we can use views by kotlinx
//val recyclerView = job_recyclerView
//Or old-fashioned way
val recyclerView = getView()!!.findViewById(R.id.job_recyclerView) as RecyclerView
}


RecylerView can be accessed from fragment's layout by having root view like: getView()!!.findViewById or by kotlinx inside onViewCreated(): job_recyclerView






share|improve this answer












It is wrong way to findViewById from Fragment(it is good technique for Activity):



val recyclerView = findViewById(R.id.job_recyclerView) as RecyclerView


First, fragment's layout have to be return by onCreateView() method.



override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_main, container, false)
}


I personally like do all fragment's business logic inside onViewCreated()



override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
//Now, we can use views by kotlinx
//val recyclerView = job_recyclerView
//Or old-fashioned way
val recyclerView = getView()!!.findViewById(R.id.job_recyclerView) as RecyclerView
}


RecylerView can be accessed from fragment's layout by having root view like: getView()!!.findViewById or by kotlinx inside onViewCreated(): job_recyclerView







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 18 at 9:10









koliczyna

21619




21619












  • Sorry, your formatting is confusing to me? It seems like your suggesting using both 'onCreateView' and 'onViewCreated', or am I reading this wrong?
    – CB Midkiff
    Nov 19 at 9:05










  • Agree with koliczyna, onViewCreated() should handle the business logic, not oncreateView(), this should just be for inflating the layout
    – Blue Jones
    Nov 19 at 9:30










  • @CB Midkiff You are correct, I suggest to use both of them.
    – koliczyna
    Nov 20 at 8:53


















  • Sorry, your formatting is confusing to me? It seems like your suggesting using both 'onCreateView' and 'onViewCreated', or am I reading this wrong?
    – CB Midkiff
    Nov 19 at 9:05










  • Agree with koliczyna, onViewCreated() should handle the business logic, not oncreateView(), this should just be for inflating the layout
    – Blue Jones
    Nov 19 at 9:30










  • @CB Midkiff You are correct, I suggest to use both of them.
    – koliczyna
    Nov 20 at 8:53
















Sorry, your formatting is confusing to me? It seems like your suggesting using both 'onCreateView' and 'onViewCreated', or am I reading this wrong?
– CB Midkiff
Nov 19 at 9:05




Sorry, your formatting is confusing to me? It seems like your suggesting using both 'onCreateView' and 'onViewCreated', or am I reading this wrong?
– CB Midkiff
Nov 19 at 9:05












Agree with koliczyna, onViewCreated() should handle the business logic, not oncreateView(), this should just be for inflating the layout
– Blue Jones
Nov 19 at 9:30




Agree with koliczyna, onViewCreated() should handle the business logic, not oncreateView(), this should just be for inflating the layout
– Blue Jones
Nov 19 at 9:30












@CB Midkiff You are correct, I suggest to use both of them.
– koliczyna
Nov 20 at 8:53




@CB Midkiff You are correct, I suggest to use both of them.
– koliczyna
Nov 20 at 8:53










up vote
0
down vote













Ok, so first of all you are getting error on findViewById bcoz your fragment is unaware about the view that contains recyclerView



What you should do is, take an instance of view that you are inflating for this fragment ( declare view as a global variable, replace your inflater line with this. )



var rootView

// Inside onCreateView
var rootView = inflater?.inflate(R.layout.fragment, container, false)


Now replace, findViewById() with rootView.findViewById()



And the other error is bcoz the fragment does not have any context of it's own so replace this with activity!!



By writing activity!! you are calling getActicity() method which returns context of parent activity.






share|improve this answer





















  • I followed your suggestions and it did take care of the compiler errors, and the app now runs. The RecyclerView does not populate as it should. I does not show up at all. I think it is how that inflater is called. But I only had a little bit of time to work on it. I've been at the immigration offices all day dealing with Visa issues. Im going to work on it more this afternoon and tonight.
    – CB Midkiff
    Nov 19 at 8:06















up vote
0
down vote













Ok, so first of all you are getting error on findViewById bcoz your fragment is unaware about the view that contains recyclerView



What you should do is, take an instance of view that you are inflating for this fragment ( declare view as a global variable, replace your inflater line with this. )



var rootView

// Inside onCreateView
var rootView = inflater?.inflate(R.layout.fragment, container, false)


Now replace, findViewById() with rootView.findViewById()



And the other error is bcoz the fragment does not have any context of it's own so replace this with activity!!



By writing activity!! you are calling getActicity() method which returns context of parent activity.






share|improve this answer





















  • I followed your suggestions and it did take care of the compiler errors, and the app now runs. The RecyclerView does not populate as it should. I does not show up at all. I think it is how that inflater is called. But I only had a little bit of time to work on it. I've been at the immigration offices all day dealing with Visa issues. Im going to work on it more this afternoon and tonight.
    – CB Midkiff
    Nov 19 at 8:06













up vote
0
down vote










up vote
0
down vote









Ok, so first of all you are getting error on findViewById bcoz your fragment is unaware about the view that contains recyclerView



What you should do is, take an instance of view that you are inflating for this fragment ( declare view as a global variable, replace your inflater line with this. )



var rootView

// Inside onCreateView
var rootView = inflater?.inflate(R.layout.fragment, container, false)


Now replace, findViewById() with rootView.findViewById()



And the other error is bcoz the fragment does not have any context of it's own so replace this with activity!!



By writing activity!! you are calling getActicity() method which returns context of parent activity.






share|improve this answer












Ok, so first of all you are getting error on findViewById bcoz your fragment is unaware about the view that contains recyclerView



What you should do is, take an instance of view that you are inflating for this fragment ( declare view as a global variable, replace your inflater line with this. )



var rootView

// Inside onCreateView
var rootView = inflater?.inflate(R.layout.fragment, container, false)


Now replace, findViewById() with rootView.findViewById()



And the other error is bcoz the fragment does not have any context of it's own so replace this with activity!!



By writing activity!! you are calling getActicity() method which returns context of parent activity.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 18 at 9:15









Kinjal Rathod

33125




33125












  • I followed your suggestions and it did take care of the compiler errors, and the app now runs. The RecyclerView does not populate as it should. I does not show up at all. I think it is how that inflater is called. But I only had a little bit of time to work on it. I've been at the immigration offices all day dealing with Visa issues. Im going to work on it more this afternoon and tonight.
    – CB Midkiff
    Nov 19 at 8:06


















  • I followed your suggestions and it did take care of the compiler errors, and the app now runs. The RecyclerView does not populate as it should. I does not show up at all. I think it is how that inflater is called. But I only had a little bit of time to work on it. I've been at the immigration offices all day dealing with Visa issues. Im going to work on it more this afternoon and tonight.
    – CB Midkiff
    Nov 19 at 8:06
















I followed your suggestions and it did take care of the compiler errors, and the app now runs. The RecyclerView does not populate as it should. I does not show up at all. I think it is how that inflater is called. But I only had a little bit of time to work on it. I've been at the immigration offices all day dealing with Visa issues. Im going to work on it more this afternoon and tonight.
– CB Midkiff
Nov 19 at 8:06




I followed your suggestions and it did take care of the compiler errors, and the app now runs. The RecyclerView does not populate as it should. I does not show up at all. I think it is how that inflater is called. But I only had a little bit of time to work on it. I've been at the immigration offices all day dealing with Visa issues. Im going to work on it more this afternoon and tonight.
– CB Midkiff
Nov 19 at 8:06


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53359022%2fandroid-kotlin-troubles-with-databinding-to-recyclerview-using-fragments%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin