List of usage examples for android.app Dialog Dialog
public Dialog(@NonNull Context context)
From source file:com.seleuco.mame4droid.NetPlay.java
public void createDialog() { netplayDlg = new Dialog(mm); netplayDlg.setContentView(R.layout.netplayview); netplayDlg.setTitle("Peer-To-Peer Netplay"); netplayDlg.setCancelable(true);/*from w w w . j a v a 2s. co m*/ netplayDlg.setOnCancelListener(dialogCancelListener); final Button startButton = (Button) netplayDlg.findViewById(R.id.StartGameBtn); startButton.setOnClickListener(createGameClick); final Button joinButton = (Button) netplayDlg.findViewById(R.id.JoinPeerGameBtn); joinButton.setOnClickListener(joinGameClick); final Button disconnectButton = (Button) netplayDlg.findViewById(R.id.DisconnectBtn); disconnectButton.setOnClickListener(disconnectGameClick); prepareButtons(); netplayDlg.show(); /* final SharedPreferences sp = mm.getPrefsHelper().getSharedPreferences(); AlertDialog.Builder builder = new AlertDialog.Builder(mm); View checkBoxView = View.inflate(mm, R.layout.wifiwarnview, null); builder.setView(checkBoxView); if (sp.getBoolean("warnWIFI", true) && mm.getMainHelper().getDeviceDetected() != MainHelper.DEVICE_OUYA) { CheckBox checkBox = (CheckBox) checkBoxView .findViewById(R.id.dontbotherCBox); checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences.Editor edit = sp.edit(); edit.putBoolean("warnWIFI", !isChecked); edit.commit(); } }); builder.setTitle("Open Wi-Fi Settings?"); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { mm.startActivity(new Intent( WifiManager.ACTION_PICK_WIFI_NETWORK)); } }); builder.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { netplayDlg.show(); } }); builder.show(); } else { netplayDlg.show(); } */ }
From source file:com.example.dany.jjdraw.MainActivity.java
@Override public void onClick(View view) { if (view.getId() == R.id.draw_btn) { final Dialog brushDialog = new Dialog(this); brushDialog.setTitle("Brush size"); brushDialog.setContentView(R.layout.brush_chooser); ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush); smallBtn.setOnClickListener(new OnClickListener() { @Override/*from ww w . j a v a 2 s . c o m*/ public void onClick(View v) { drawView.setBrushSize(smallBrush); drawView.setLastBrushSize(smallBrush); drawView.setErase(false); brushDialog.dismiss(); } }); ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush); mediumBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(mediumBrush); drawView.setLastBrushSize(mediumBrush); drawView.setErase(false); brushDialog.dismiss(); } }); ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush); largeBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(largeBrush); drawView.setLastBrushSize(largeBrush); drawView.setErase(false); brushDialog.dismiss(); } }); brushDialog.show(); } else if (view.getId() == R.id.erase_btn) { //switch to erase - choose size final Dialog brushDialog = new Dialog(this); brushDialog.setTitle("Eraser size"); brushDialog.setContentView(R.layout.brush_chooser); ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush); smallBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { drawView.setErase(true); drawView.setBrushSize(smallBrush); brushDialog.dismiss(); } }); ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush); mediumBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { drawView.setErase(true); drawView.setBrushSize(mediumBrush); brushDialog.dismiss(); } }); ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush); largeBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { drawView.setErase(true); drawView.setBrushSize(largeBrush); brushDialog.dismiss(); } }); brushDialog.show(); } else if (view.getId() == R.id.new_btn) { //new button AlertDialog.Builder newDialog = new AlertDialog.Builder(this); newDialog.setTitle("New drawing"); newDialog.setMessage("Start new drawing (you will lose the current drawing)?"); newDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { drawView.startNew(null); dialog.dismiss(); } }); newDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); newDialog.show(); } else if (view.getId() == R.id.save_btn) { //save drawing AlertDialog.Builder saveDialog = new AlertDialog.Builder(this); saveDialog.setTitle("Save drawing"); saveDialog.setMessage("Save drawing to device Gallery?"); saveDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //save drawing drawView.setDrawingCacheEnabled(true); String imgSaved = MediaStore.Images.Media.insertImage(MainActivity.this.getContentResolver(), drawView.getDrawingCache(), UUID.randomUUID().toString() + ".png", "drawing"); if (imgSaved != null) { Toast savedToast = Toast.makeText(getApplicationContext(), "Drawing saved to Gallery!", Toast.LENGTH_SHORT); savedToast.show(); } else { for (int i = 0; i < 3; i++) { // tried to increase the duration Toast unsavedToast = Toast.makeText(getApplicationContext(), "Oops! Image could not be saved. " + "Explicit write permission to storage device may required." + "Check Settings->" + "Application Manager->" + "JJDraw->" + "Permissions.", Toast.LENGTH_LONG); unsavedToast.show(); } } drawView.destroyDrawingCache(); } }); saveDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); saveDialog.show(); } }
From source file:com.aqnote.app.wifianalyzer.wifi.AccessPointsDetail.java
@NonNull public Dialog popupDialog(@NonNull Context context, @NonNull LayoutInflater inflater, @NonNull WiFiDetail wiFiDetail) { View view = inflater.inflate(R.layout.access_points_details_popup, null); Dialog dialog = new Dialog(context); dialog.setContentView(view);//from w ww . java2 s . co m setView(context.getResources(), view, wiFiDetail, false); dialog.findViewById(R.id.popupButton).setOnClickListener(new PopupDialogListener(dialog)); return dialog; }
From source file:io.spw.hello.SectionsPagerAdapter.java
public void showMatchDialog() throws JSONException, ParseException { final Dialog dialog = new Dialog(mActivity); dialog.setContentView(R.layout.dialog_match_made); dialog.setTitle("An introduction is the essence of possibility"); // find views TextView userName0 = (TextView) dialog.findViewById(R.id.userName0); TextView userInfo0 = (TextView) dialog.findViewById(R.id.userInfo0); TextView userName1 = (TextView) dialog.findViewById(R.id.userName1); TextView userInfo1 = (TextView) dialog.findViewById(R.id.userInfo1); TextView userName2 = (TextView) dialog.findViewById(R.id.userName2); TextView userInfo2 = (TextView) dialog.findViewById(R.id.userInfo2); Button helloButton = (Button) dialog.findViewById(R.id.dialog_hello_button); // get member users JSONArray userIds = currentUser.getJSONArray(ParseConstants.KEY_MEMBER_IDS); ParseRelation<ParseUser> groupMembersRelation = currentUser .getRelation(ParseConstants.KEY_GROUP_MEMBERS_RELATION); List<ParseUser> users = new ArrayList<>(); for (int i = 0; i < userIds.length(); i++) { if (!currentUser.getObjectId().equals(userIds.getString(i))) { ParseUser user = ParseUser.getQuery().get(userIds.getString(i)); users.add(user);/*from w w w. jav a 2s .c o m*/ groupMembersRelation.add(user); } } // set text userName0.setText(users.get(0).getString(ParseConstants.KEY_FIRST_NAME)); userInfo0.setText(users.get(0).getString(ParseConstants.KEY_AGE) + " // " + (users.get(0).getString(ParseConstants.KEY_HOMETOWN))); userName1.setText(users.get(1).getString(ParseConstants.KEY_FIRST_NAME)); userInfo1.setText(users.get(1).getString(ParseConstants.KEY_AGE) + " // " + (users.get(1).getString(ParseConstants.KEY_HOMETOWN))); userName2.setText(users.get(2).getString(ParseConstants.KEY_FIRST_NAME)); userInfo2.setText(users.get(2).getString(ParseConstants.KEY_AGE) + " // " + (users.get(2).getString(ParseConstants.KEY_HOMETOWN))); // set button helloButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { currentUser.put(ParseConstants.KEY_MATCH_DIALOG_SEEN, true); currentUser.saveInBackground(); if (mFirstFragment instanceof ThisWeekendFragment) { switchToGroupChatFragment(); } dialog.dismiss(); } }); dialog.show(); }
From source file:com.example.yudiandrean.socioblood.FeedActivity.java
@SuppressLint("NewApi") @Override// w w w.j a va 2 s.co m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Dialog d = new Dialog(context); setContentView(R.layout.feed_activity); postrequest = (TextView) findViewById(R.id.editText); WindowManager manager = (WindowManager) getSystemService(Activity.WINDOW_SERVICE); final int width, height; ActionBar.LayoutParams params; if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { width = manager.getDefaultDisplay().getWidth(); height = manager.getDefaultDisplay().getHeight(); } else { Point point = new Point(); manager.getDefaultDisplay().getSize(point); width = point.x; height = point.y; } session = new SessionManager(getApplicationContext()); // Check if user is already logged in or not if (!session.isLoggedIn()) { // User is already logged in. Take him to main activity Intent intent = new Intent(FeedActivity.this, LoginActivity.class); startActivity(intent); finish(); } listView = (ListView) findViewById(R.id.list); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeContainer); feedItems = new ArrayList<FeedItem>(); listAdapter = new FeedListAdapter(this, feedItems); listView.setAdapter(listAdapter); swipeRefreshLayout.setOnRefreshListener(this); // add button listener postrequest.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { try { d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setContentView(R.layout.post_request); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(d.getWindow().getAttributes()); lp.width = width; lp.height = height; d.getWindow().setAttributes(lp); } catch (AndroidRuntimeException e) { } catch (Exception e) { } final Spinner rhesusspinner = (Spinner) d.findViewById(R.id.rhesus_spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(FeedActivity.this, android.R.layout.simple_spinner_dropdown_item) { @Override public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); if (position == getCount()) { ((TextView) v.findViewById(android.R.id.text1)).setText(""); ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed" } return v; } @Override public int getCount() { return super.getCount() - 1; // you dont display last item. It is used as hint. } }; adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.add("+"); adapter.add("-"); adapter.add("Rhesus"); rhesusspinner.setAdapter(adapter); rhesusspinner.setSelection(adapter.getCount()); //display hint final Spinner bloodspinner = (Spinner) d.findViewById(R.id.bloodtype_spinner); ArrayAdapter<String> bloodadapter = new ArrayAdapter<String>(FeedActivity.this, android.R.layout.simple_spinner_dropdown_item) { @Override public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); if (position == getCount()) { ((TextView) v.findViewById(android.R.id.text1)).setText(""); ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed" } return v; } @Override public int getCount() { return super.getCount() - 1; // you dont display last item. It is used as hint. } }; bloodadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); bloodadapter.add("O"); bloodadapter.add("A"); bloodadapter.add("B"); bloodadapter.add("AB"); bloodadapter.add("Desired Type"); bloodspinner.setAdapter(bloodadapter); bloodspinner.setSelection(bloodadapter.getCount()); //display hint //Buttons-Editexts Button btnpost = (Button) d.findViewById(R.id.post); final EditText userInput = (EditText) d.findViewById(R.id.editTextDialogUserInput); d.show(); btnpost.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (bloodspinner.getSelectedItem().toString().equals("Desired Type")) { Toast.makeText(getApplicationContext(), "Input Blood Type!", Toast.LENGTH_SHORT).show(); } else if (rhesusspinner.getSelectedItem().toString().equals("Rhesus")) { Toast.makeText(getApplicationContext(), "Input Rhesus!", Toast.LENGTH_SHORT).show(); } else if (userInput.getText().toString().equals("")) { Toast.makeText(getApplicationContext(), "Input your request message!", Toast.LENGTH_SHORT).show(); } else { int uid = session.currentUID(); String message = userInput.getText().toString(); String post_bloodtype = bloodspinner.getSelectedItem().toString(); String post_rhesus = rhesusspinner.getSelectedItem().toString(); NetAsync(d, view, uid, message, post_bloodtype, post_rhesus); } } }); } }); // // We first check for cached request // Cache cache = FeedController.getInstance().getRequestQueue().getCache(); // Entry entry = cache.get(URL_FEED); // if (entry != null) { // // fetch the data from cache // try { // String data = new String(entry.data, "UTF-8"); // try { // parseJsonFeed(new JSONObject(data)); // } catch (JSONException e) { // e.printStackTrace(); // } // } catch (UnsupportedEncodingException e) { // e.printStackTrace(); // } // // } else { // making fresh volley request and getting json /** * Showing Swipe Refresh animation on activity create * As animation won't start on onCreate, post runnable is used */ swipeRefreshLayout.post(new Runnable() { @Override public void run() { swipeRefreshLayout.setRefreshing(true); getTimelineAsync(); } }); }
From source file:com.meetingninja.csse.user.UserListFragment.java
public void addContactsOptionLoaded() { dlg = new Dialog(getActivity()); dlg.setTitle("Search by name or email:"); View autocompleteView = getActivity().getLayoutInflater().inflate(R.layout.fragment_autocomplete, null); final ContactTokenTextView input = (ContactTokenTextView) autocompleteView .findViewById(R.id.my_autocomplete); autoAdapter = new AutoCompleteAdapter(getActivity(), allUsers); input.setAdapter(autoAdapter);/* w w w .j a v a 2s . co m*/ input.setTokenListener(this); dlg.setContentView(autocompleteView); dlg.show(); }
From source file:de.hero.vertretungsplan.PrefsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); ListPreference listPref = (ListPreference) findPreference("prefs_benachrichtigungsintervall"); listPref.setSummary(//from w ww . ja va 2s . co m getSummaryInterval(mySharedPreferences.getString("prefs_benachrichtigungsintervall", "1"))); listPref.setOnPreferenceChangeListener(new ListPreference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { preference.setSummary(getSummaryInterval(newValue.toString())); MainActivity.setNewAlarm(getBaseContext(), true, newValue.toString()); return true; } }); Preference klasse = findPreference("prefs_klasse"); klasse.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { showDialog(R.string.dialog_klasse); return true; } }); CheckBoxPreference ckBxPref = (CheckBoxPreference) findPreference("prefs_benachrichtigungen"); ckBxPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals("prefs_benachrichtigungen")) { MainActivity.setNewAlarm(getBaseContext(), !((CheckBoxPreference) preference).isChecked(), mySharedPreferences); } return true; } }); CheckBoxPreference ckBxPrefAppUpdate = (CheckBoxPreference) findPreference("prefs_check_for_app_updates"); ckBxPrefAppUpdate.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals("prefs_check_for_app_updates")) { Intent i = new Intent(getBaseContext(), CheckForAppUpdate.class); i.putExtra("setTimer", !((CheckBoxPreference) preference).isChecked()); if (!((CheckBoxPreference) preference).isChecked()) { i.putExtra("checkNow", true); } getBaseContext().startService(i); } return true; } }); Preference ueber = findPreference("ueber"); ueber.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Dialog ueberDialog = new Dialog(PrefsActivity.this); ueberDialog.setContentView(R.layout.ueber_dialog_layout); ueberDialog.setTitle(getString(R.string.ueber)); ueberDialog.setCancelable(true); ueberDialog.setCanceledOnTouchOutside(true); TextView dialogText = (TextView) ueberDialog.findViewById(R.id.text_in_dialog); dialogText.setTextColor(Color.BLACK); dialogText.setAutoLinkMask(Linkify.ALL); dialogText.setText(String.format(getString(R.string.ueberTextFormated), getString(R.string.version_nr), getString(R.string.emailAdresseEntwickler), getString(R.string.webAdresseAppDownload), getString(R.string.GNU_GPLwebadresse))); ueberDialog.show(); return true; } }); CheckBoxPreference ckBxPrefDebugging = (CheckBoxPreference) findPreference("prefs_debug"); ckBxPrefDebugging.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals("prefs_debug")) { Log.d("PrefsActivity", "new"); if (!((CheckBoxPreference) preference).isChecked()) { AlertDialog.Builder builder = new AlertDialog.Builder(preference.getContext()); builder.setMessage(getString(R.string.debugText)).setTitle(getString(R.string.debugTitel)); AlertDialog dialog = builder.create(); dialog.show(); } } return true; } }); }
From source file:com.zpwebsites.linuxonandroid.Install_Archlinux_2.java
private void downloadImage(Context context, final String torrentName, final String sourceforgeName) { if (torrentName.equals("")) { Intent localIntent = new Intent("android.intent.action.VIEW"); localIntent.setData(Uri.parse(sourceforgeName)); startActivity(localIntent);/*from w w w. j a v a 2 s. co m*/ return; } final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_download_type_selector); dialog.setCancelable(true); Button btn_Torrent = (Button) dialog.findViewById(R.id.btn_Torrent); btn_Torrent.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent localIntent = new Intent("android.intent.action.VIEW"); localIntent.setData(Uri.parse(torrentName)); startActivity(localIntent); dialog.dismiss(); } }); Button btn_Sourceforge = (Button) dialog.findViewById(R.id.btn_Sourceforge); btn_Sourceforge.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent localIntent = new Intent("android.intent.action.VIEW"); localIntent.setData(Uri.parse(sourceforgeName)); startActivity(localIntent); dialog.dismiss(); } }); Button btn_Cancel = (Button) dialog.findViewById(R.id.btn_Cancel); btn_Cancel.setOnClickListener(new OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }
From source file:com.tingtingapps.securesms.ConversationListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { final View view = inflater.inflate(R.layout.conversation_list_fragment, container, false); reminderView = (ReminderView) view.findViewById(R.id.reminder); list = (RecyclerView) view.findViewById(R.id.list); fab = (FloatingActionButton) view.findViewById(R.id.fab); list.setHasFixedSize(true);/*from w w w .j ava2s . co m*/ list.setLayoutManager(new LinearLayoutManager(getActivity())); Calendar calendar = Calendar.getInstance(); int day = calendar.get(Calendar.DAY_OF_WEEK); int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); SharedPreferences sp1 = getActivity().getSharedPreferences("myPrefs", Activity.MODE_PRIVATE); int dayShowPopup = sp1.getInt("dayShowPopup", 0); /* //test data day = 7; dayShowPopup = 15; dayOfMonth = 26;*/ if (day == 7 && dayOfMonth != dayShowPopup) { SharedPreferences sp2 = getActivity().getSharedPreferences("myPrefs", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = sp2.edit(); editor.putInt("dayShowPopup", dayOfMonth); editor.commit(); final Dialog dialogRating = new Dialog(getActivity()); dialogRating.requestWindowFeature(Window.FEATURE_NO_TITLE); dialogRating.setContentView(R.layout.dlg_rating_sharing_donating); int height = 850; dialogRating.getWindow().setLayout(LinearLayout.LayoutParams.FILL_PARENT, height); dialogRating.setCancelable(true); dialogRating.show(); Button btnRate = (Button) dialogRating.findViewById(R.id.btn_rate); btnRate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Context context = getActivity().getApplicationContext(); String packageName = context.getPackageName(); Intent intentRateApp = new Intent(Intent.ACTION_VIEW); intentRateApp.setData(Uri.parse("market://details?id=" + packageName)); startActivity(intentRateApp); } }); /*Button btnRemoveAds = (Button) dialogRating.findViewById(R.id.btn_remove_ads); btnRemoveAds.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intentInAppBilling = new Intent(getActivity(), InAppBillingActivity.class); startActivity(intentInAppBilling); } });*/ Button btnShare = (Button) dialogRating.findViewById(R.id.btn_share); btnShare.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBody = getString(R.string.socail_share_body); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.socail_share_title)); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody); startActivity(Intent.createChooser(sharingIntent, getString(R.string.socail_share_via))); } }); Button btnClose = (Button) dialogRating.findViewById(R.id.btn_close); btnClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialogRating.dismiss(); } }); } return view; }
From source file:com.procleus.brime.ui.LabelsFragment.java
@Override public void onResume() { super.onResume(); NotesDbHelperOld tn = new NotesDbHelperOld(getContext()); labelsRetrieved = tn.retrieveLabel(); listView = (ListView) getView().findViewById(R.id.listLabel); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1, labelsRetrieved); listView.setAdapter(arrayAdapter);// w w w .j a va 2 s. c om listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) { final Dialog dialog = new Dialog(getContext()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.setCancelable(false); dialog.setContentView(R.layout.dialog_label); dialog.show(); final Button negative = (Button) dialog.findViewById(R.id.btn_no_label); final Button positive = (Button) dialog.findViewById(R.id.btn_yes_label); /*/This is Database Spinner Retreival*/ /* Spinner getting Data from dataBase*/ negative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); positive.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("brinjalResume", "Yes"); NotesDbHelperOld tn = new NotesDbHelperOld(getActivity()); tn.deleteTextNote(String.valueOf(parent.getItemAtPosition(position))); labelsRetrieved = tn.retrieveLabel(); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1, labelsRetrieved); listView.setAdapter(arrayAdapter); dialog.dismiss(); } }); return true; } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(getActivity(), "Inside in label" + ":" + String.valueOf(parent.getItemAtPosition(position)), Toast.LENGTH_SHORT).show(); Intent i = new Intent(getActivity(), LabelOpenActivity.class); i.putExtra("label", String.valueOf(parent.getItemAtPosition(position))); startActivity(i); } }); }