私は非常に基本的なアプリケーションを持っており、ツールバーにチェックボックスを入れようとしています。ツールバーのカスタムボタンがアクションに応答しません。トーストは表示されません
これは私のxmlがどのように見えるかです:
私は、単純なリスナー設定している私のMainActivityで<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="xxxxxxxx.xx.xx.HomeActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:padding="5dp"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText
android:id="@+id/searchET"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="8"
android:background="@android:color/white"/>
<CheckBox
android:id="@+id/favorite_toggle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_home" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
:
favoriteBtn = (CheckBox) findViewById(R.id.favorite_toggle);
favoriteBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if(isChecked){
Toast.makeText(HomeActivity.this, "changed", Toast.LENGTH_SHORT);
addFavorite(url);
}else{
Toast.makeText(HomeActivity.this, "again changed", Toast.LENGTH_SHORT);
removeFavorite(url);
}
}
});
私は、チェックボックスをクリックすると、何も起こりません、チェックボックスが切り替わりますが、私をトーストを見ないでください。 ViewPostImeInputStage processPointer 1
は、誰かが私に間違っている可能性がどのように方向性を与えることができます:私はlogcat
に次のメッセージD/ViewRootImplを参照してください?
更新:私はそのトーストが表示されないと思う。
ew ..はい私は非常に何かが間違っていたと確信していた。私はそれを逃した。 –