I have a data binding layout that contains a frame layout with <include>
of other layout inside:
<FrameLayout
android:id="@+id/global_actions_frame_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.075"
android:background="@color/colorToolBar">
<include
android:id="@+id/included"
layout="@layout/global_actions">
</include>
</FrameLayout>
the layout has image buttons inside in this format:
<ImageButton
android:id="@+id/settingsButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_settings_black_36dp"
android:layout_gravity="end"
android:background="@color/colorToolBar"
android:layout_margin="4dp"
android:layout_marginLeft="20dp"
android:onClick="@{listener::onClickState}"
android:alpha="0.4"/>
and I added the tag around them and I added data with name of activity
<data>
<import type="android.view.View"/>
<variable name="listener" type="MyActivity"/>
</data>
and in MyActivity I called a function to listen to On click from the image buttons:
public void onClickState(View view){
int id = view.getId();
}
but from some reason I don't get to this function when I click
I tried also
android:onClick="@{listener.onClickState}"
but nothing helped.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…