@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // Switch to login activity case R.id.button_add: // Check if user currently logged in currentUser = ParseUser.getCurrentUser(); if (currentUser == null) { Toast.makeText(getApplicationContext(), "Please log in to add items.", Toast.LENGTH_SHORT) .show(); Intent intentLoginAdd = new Intent(getApplicationContext(), LoginActivity.class); intentLoginAdd.putExtra("resName", resName); startActivity(intentLoginAdd); return false; } // Show dialog box for adding user data FragmentTransaction ft = getFragmentManager().beginTransaction(); final AddDialogFragment dfrag = AddDialogFragment.newInstance(resName); // final AddDialogFragment dfrag = new AddDialogFragment(); dfrag.show(ft, "add"); return true; default: return super.onOptionsItemSelected(item); } }
private void showPopup() { AddDialogFragment popup = new AddDialogFragment(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); DialogFragment newFragment = AddDialogFragment.newInstance(1); newFragment.show(ft, "dialog"); }