i have recyclerview in my App and when list item is pressed bottomsheet dialog expends where i have two buttons but i can't set click listeners to it. This is onClick method in adapter
BottomSheetDialog offer_info_dialog;
RelativeLayout rel;
Button Yes,No;
View parentView;
@Override
public void onClick(View view) {
rel = (RelativeLayout) activity.findViewById(R.id.bottomsheet);
Yes = (Button) offer_info_dialog.findViewById(R.id.confirm_btn_on_info);
No = (Button) offer_info_dialog.findViewById(R.id.cancel_btn_on_info);
offer_info_dialog = new BottomSheetDialog(context);
LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
parentView = inflater.inflate(R.layout.offer_info_layout, null);
offer_info_dialog.setContentView(parentView);
((View) parentView.getParent()).setBackgroundColor(context.getResources().getColor(android.R.color.transparent));
offer_info_dialog.show();
rel.setVisibility(View.INVISIBLE);
Yes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MainActivity.removeCheatOfferMarkers(2);
}
});
No.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from((View) parentView.getParent());
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
});
offer_info_dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
rel.setVisibility(View.VISIBLE);
}
});
}
and this is an error:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.support.design.widget.BottomSheetDialog.findViewById(int)' on a null object reference