I need help so I have a fragment which has a RecycleView and inside the RecycleView there is a button.
The button after click must open the dialog which already declared in base fragment so I only call like openDialog(DIALOG_CHECK); 
Now how can I call that dialog on my adapter I already make a method in fragment and call it from the adapter and make an error "Java lang null pointer"
This is my code :
DeliveryFragment delivFrag = new DeliveryFragment();
holder.editButton.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {
         delivFrag.doEdit();
     }
});
And in fragment
public void doEdit(){
   openDialog(DIALOG_EDIT_ITEM);
}
                Update your adapter constructor to accept the Fragment as a parameter.
customAdapter = new CustomAdapter(myContext, android.R.layout.simple_list_item_1, getList, HomeFragment.this);
Adapter Class:
public CustomAdapter(Context context, int id, HomeFragment fragment) {
    this.fragment = fragment;
}
Call in Adapter :
((FragmentName)fragment).methodName();
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With