Author | Message |
---|---|
DGALLEG7
Posts: 13
|
Posted 16:14 Nov 11, 2019 |
win we inflate the binding variable we set val binding = DataBindingUtil.inflate<FragmentTitleBinding>(blah.....) and we
import com.example.android.navigation.databinding.FragmentTitleBinding
but it wont work outside of the code labs starter code.
Are we suppose to use the template code for the projects?? If not what would I use in its place so I can complete the databinding |
akaur21
Posts: 8
|
Posted 16:19 Nov 11, 2019 |
To enable that class, your fragment layout should be enclosed inside layout tags: <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> // your fragment layout </layout> |
Max O.
Posts: 1
|
Posted 16:19 Nov 11, 2019 |
The path might be slightly different than the examples. This is what I had to import for it to work for one of my fragments:
import com.example.multiapp.databinding.FragmentDierollerBinding |
DGALLEG7
Posts: 13
|
Posted 16:28 Nov 11, 2019 |
|
DGALLEG7
Posts: 13
|
Posted 16:30 Nov 11, 2019 |
|
akaur21
Posts: 8
|
Posted 16:34 Nov 11, 2019 |
Your linear layout should be enclosed in those outer layout tags. |
DGALLEG7
Posts: 13
|
Posted 16:37 Nov 11, 2019 |
|
dvictor4
Posts: 34
|
Posted 16:43 Nov 11, 2019 |
FragmentDierollerBinding is created for you (Just like the R class) to easily get the views in a fragment. It is created when you wrap everything inside <layout></layout> and include dataBinding { enabled = true } inside build.gradle file. It lets you do binding.viewInsideFragment instead of findViewById<viewInsideFragment>(R.id.idOfViewInsideFragment)
|
DGALLEG7
Posts: 13
|
Posted 16:45 Nov 11, 2019 |
Thank you thats what I was looking for |