I am newbie to DataBinding in Android and learning it to my own. I have just enabled the DataBinding in my App Gradle File in the Android Tag as:
dataBinding{
enabled=true
}
My XML is setup like this:
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<RelativeLayout
tools:showIn="@layout/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"/>
</RelativeLayout>
</layout>
And my Activity Looks like:
The problem is that the ActivityMainBinding Class is unknown to Android Studio. I don't know why is this happening. As I had clean, re-build make the project and everything doesn't help me out!
I am attaching an [screen shot][1] too, looking at the screenshot you can find that the ActivityMainBinding is highlighted in RED COLOR
It was totally strange because Its ANDROID STUDIO!
What I done is just changed the name of the activity_main.xml to activity_main_.xml then I make the project!
After Making the project, I reverted back to the old name i.e activity_main.xml and it works like a charm. Don't know but it works really because this GooF Android Studio doesn't even ever makes any sense!