Created a custom DialogFragment with add. methods for quickly building a dialogue from the activit.
public abstract class ShoppingDialogFragment extends DialogFragment { public AlertDialog.Builder mBuilder; public ShoppingDialogFragment setTitle(String title) { mBuilder.setTitle(title); return this; } public ShoppingDialogFragment getBuilder() { this.mBuilder = new AlertDialog.Builder(getActivity()); return this; } public ShoppingDialogFragment setView(int r) { LayoutInflater inflater = getActivity().getLayoutInflater(); View v = inflater.inflate(r, null); mBuilder.setView(v); return this; } public Dialog create() { return mBuilder.create(); } @Override public abstract Dialog onCreateDialog(Bundle savedInstanceState); } When I create an instance of this class, the studio emphasizes the class and warns: "Fragments should not be static"
ShoppingDialogFragment shoppingDialogFragment = new ShoppingDialogFragment() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return getBuilder().setTitle("test").setView(R.layout.test).create(); } }; shoppingDialogFragment.show(getFragmentManager(), null); The application works, but this warning confuses me. Did I do everything right and will this not affect the work of the application in the future?