I'm using android data bindings and also using Dragger the problem is when I do this
MyLayoutbinding = DataBindingUtil.setContentView(this, R.layout.my_Layout);
I got the error
Caused by: java.lang.RuntimeException: view tag isn't correct on view:null
at com.rkmax.myapp.databinding.MyLayoutBinding.bind(MyLayoutBinding.java:191)
at android.databinding.DataBinderMapper.getDataBinder(DataBinderMapper.java:15)
at android.databinding.DataBindingUtil.bind(DataBindingUtil.java:185)
at android.databinding.DataBindingUtil.bindToAddedViews(DataBindingUtil.java:299)
at android.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:279)
at android.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:261)
at com.rkmax.myapp.MyActivity.onCreate(MyActivity.java:26)
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<import type="android.graphics.drawable.Drawable" />
<variable name="indicatorBg" type="Drawable" />
<variable name="categoryName" type="String" />
<variable name="progress" type="int" />
</data>
<RelativeLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_blackboard">
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="15.3dp"
android:id="@+id/progressBar2"
android:max="10"
android:progress="@{progress}" />
</RelativeLayout>
</layout>
After a lot of trial and error what I did was copy the DraggerActivity source to and create my own DraggerActivity then add the following methods
private void configViews(View root) {
this.draggerPanel.addViewOnDrag(root);
if(this.shadowResID == -1) {
this.shadowResID = com.github.ppamorim.dragger.R.layout.layout_shadow;
}
this.draggerPanel.addViewOnShadow(this.inflateLayout(this.shadowResID));
super.setContentView(this.draggerPanel);
}
public void setContentView(View root) {
this.configDraggerView();
this.configViews(root);
super.setContentView(this.draggerPanel);
}
then on the onCreate method
View rootView = getLayoutInflater().inflate(R.layout.my_Layout, null, false);
mBinding = DataBindingUtil.bind(rootView);
setContentView(rootView);
in that way I get enable data bindings to my DraggerActivity