Home > Mobile >  The include about databinding
The include about databinding

Time:12-25

The main XML
 
<? The XML version="1.0" encoding="utf-8"?>
XMLNS: app="http://schemas.android.com/apk/res-auto"
XMLNS: bind="http://schemas.android.com/apk/res-auto"
XMLNS: tools="http://schemas.android.com/tools" & gt;



Name="activity"
Type="XXX, XXX. XXX. XXActivity"/& gt;


Android: layout_width="match_parent"
Android: layout_height="match_parent"
Android: background="@ color/color_bg"
Android: orientation="vertical" & gt;
The android: id="@ + id/include"
Layout="@ layout/include_recycler
"Android: layout_width="match_parent"
Android: layout_height="match_parent"
The bind: activity="@ {activity}"/& gt;





The include file
 
<? The XML version="1.0" encoding="utf-8"?>




"Type="XXX, XXX. XXX. XXActivity"/& gt;


<frameLayout XMLNS: android="http://schemas.android.com/apk/res/android"
Android: layout_width="match_parent"
Android: layout_height="match_parent" & gt;

Android: layout_width="match_parent"
Android: layout_height="match_parent"
The android: onClick="@ {() - & gt; Activity. DealClick ()} "& gt;

Android: layout_width="wrap_content"
Android: layout_height="wrap_content"
Android: layout_centerInParent="true"
The android: SRC="https://bbs.csdn.net/topics/@mipmap/ic_placeholder"/& gt;


The android: id="@ + id/recycler_view"
Android: layout_width="match_parent"
Android: layout_height="match_parent"
Android: layout_marginTop="12 dp/& gt;"






The include files is a general layout, such as bar, above the click event is return to the previous page, use the findviewbyid, because id, click event is the same code, but use databinding, due to the incoming activity, different activity is certainly not general,

What's the solution?
  • Related