I have create a custom layout as show below. I want to perform the databinding with this layout. How can I perform this task.
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<TextView
android:id="@+id/no_internetConnection_Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_toRightOf="@+id/icon_noInternet_connection"
android:text="@string/no_Internet_Connection_text" />
</LinearLayout>
</layout>
Here is the existing code. How can i replace the existing code with databinding code.
public class NetworkConnectionCheck {
private Context _context;
public NetworkConnectionCheck(Context _context) {
this._context = _context;
}
public void CustomToastShow() {
LayoutInflater inflater = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate( R.layout.customtoast, null );
TextView text = (TextView) view.findViewById(R.id.no_internetConnection_Text);
ImageView imageView = (ImageView) view.findViewById(R.id.icon_noInternet_connection);
Toast toast = new Toast(_context);
toast.setGravity(Gravity.BOTTOM|Gravity.FILL_HORIZONTAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(view);
toast.show();
}
}
Currently I am getting an error. This is because of Layout tag .
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class layout