저는 아주 기본적인 응용 프로그램을 가지고 있으며 툴바에 체크 상자를 넣으려고합니다.ToolBar의 사용자 지정 단추가 작업에 응답하지 않습니다. 토스트가 표시되지 않습니다.
이 내 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);
}
}
});
것은 내가 체크 박스를 클릭 I, 아무 일도 발생하지 않습니다, 체크 박스 토글하지만, 축배를 보지 마라. ViewPostImeInputStage processPointer 1
누군가가 나에게 잘못 될 수 있는지에 대한 방향을 제시 할 수 : 나는
D가/ViewRootImpl가 로그 캣의 메시지를 다음을 참조하십시오?
업데이트 : 나는 그 토스트가 나타나지 않는다고 생각합니다.
ew .. 예. 나는 무언가가 잘못되었다는 것을 확신했다. 나는 그것을 놓쳤다. –