我通过引入关闭按钮来更新现有代码,而onClick Butterknife方法不适用于关闭按钮,而适用于关闭按钮。在下面的代码中,我为某些设备启用了关闭按钮,而对于其他设备,则启用了关闭按钮。我非常不确定为什么这个“关闭”按钮不起作用,而关闭按钮却可以正常工作。他们俩都使用Butterknife,onClick方法-onSkip()
InfoActivity.java:
public class InfoActivity extends BccActiviy {
@BindView(R.id.ImageView_CloseView)
ImageView tCloseView;
@BindView(R.id.Dismiss)
Button tDismiss;
.....
@OnClick({R.id.Dismiss, R.id.ImageView_CloseView})
public void onSkip(View v) {
onDissmissPressed();
}
public void initialize(Bundle savedInstanceState) {
if (tConfig.isDismiss()) {
tCloseView.setVisibility(View.GONE);
tDismiss.setVisibility(View.VISIBLE);
} else {
tDismiss.setVisibility(View.GONE);
}
}
}
info_screen.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:ignore="All"
android:id="@+id/root_layout"
android:background="@color/fd_theme"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/ImageView_CloseView"
style="@style/CancelButton"
android:layout_width="@di/target_size"
android:layout_marginTop="@di/p_6"
android:layout_height="@di/target_size"
android:layout_alignParentStart="true"
android:clickable="true"
android:contentDescription="@string/close_btn_txt"
android:importantForAccessibility="yes"
android:paddingStart="@di/p_14"
android:paddingEnd="@di/p_14"
android:background="?attr/bg_color"
app:srcCompat="@drawable/icn_close_white"/>
<LinearLayout
android:id="@+id/TextView_Layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/TextContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@di/size_2x"
android:focusableInTouchMode="true"
android:gravity="center"
android:text="@string/text"
android:textColor="@color/white"
android:textSize="@di/rating"
android:textAlignment="center"/>
<com.package.button.star.views.widgets.StaView
android:id="@+id/StarView_AppRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center">
</com.package.button.star.views.widgets.StarView>
<Button
android:id="@+id/Dismiss"
style="@style/buttonStyle"
android:layout_marginTop="@di/margin_top"
android:paddingLeft="@di/padding_50"
android:paddingTop="@di/padding_18"
android:paddingRight="@di/padding_50"
android:paddingBottom="@di/padding_18"
android:text="Dismiss"
android:onClick="onSkip"
android:textAlignment="center"
android:textAllCaps="false"
android:textSize="@di/dismiss_fontSize"
android:visibility="visible"
android:focusable="true"
tools:text="Dismiss" />
<ViewStub
android:id="@+id/actions_stub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@di/margin_center"
android:inflatedId="@+id/view_actions"
android:layout="@layout/view_actions" />
</LinearLayout>
</FrameLayout>
答案 0 :(得分:0)
尝试从xml中删除onClick。