액티비티에 포함 된 조각에 플로팅 액션 단추를 추가했습니다. 사용자가 클릭하면 새로운 활동이 시작되지만 아무 일도 일어나지 않습니다.조각에있는 팹이 클릭 이벤트에 응답하지 않는 이유는 무엇입니까?
public class ReviewFragment extends Fragment {
@BindView(R.id.add_review_fab) FloatingActionButton mAddReviewButton;
private OnReviewNext mListener;
public ReviewFragment() {
// Required empty public constructor
}
public interface OnReviewNext {
void finishReview(String description);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_review, container, false);
ButterKnife.bind(this, view);
mAddReviewButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), AddReviewActivity.class);
startActivity(intent);
}
});
return view;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnReviewNext) {
mListener = (OnReviewNext) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnReviewNext");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
}
왜 팹이이 활동에 의해 처리되어야, 클릭 이벤트에 응답하지 않습니다
여기<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.neutronstar.revu.fragment.FeedFragment">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/review_recycler_view"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_review_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@drawable/ic_add_white_24dp"
android:clickable="true"/>
</android.support.design.widget.CoordinatorLayout>
이 조각 클래스입니다 : 여기
는 조각 레이아웃입니까?미리 감사드립니다.
확답 estion- 당신은 데이터 바인딩을 사용하고 findViewById를 피할 수 있습니다. 어쨌든 디버깅을 시도하고 onClick에서 로그를 남깁니다. – Raghunandan