Not alerting in fragment
Code fmonday.java (PS: To prevent the code from getting too long, I deleted some pieces where the loader is used):
public class fmonday extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> { final int DIALOG_ITEMS = 1; final CharSequence[] items = {"1", "2", "3"}; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fmonday, container, false); Button button12 = (Button) rootView.findViewById(R.id.button12); button12.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().showDialog(DIALOG_ITEMS); } }); } @Override //Здесь ошибка protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ITEMS: AlertDialog.Builder adb = new AlertDialog.Builder(getActivity()); adb.setTitle("Adding class"); adb.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { Toast.makeText(getActivity().getApplicationContext(), "Your choice: " + items[item], Toast.LENGTH_SHORT).show(); } }); adb.setCancelable(false); return adb.create(); default: return null; } } logcat:
Error: (88, 5) error method
How to solve this problem?
Dialog Fragment, the error remained the same. Did not help - ABL