List of usage examples for android.content DialogInterface.OnClickListener DialogInterface.OnClickListener
DialogInterface.OnClickListener
From source file:com.andreadec.musicplayer.MainActivity.java
private void equalizerSettings() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.equalizer); View view = getLayoutInflater().inflate(R.layout.layout_equalizer, null); builder.setView(view);/*from w w w . j av a 2s .co m*/ builder.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { updateExtendedMenu(); } }); builder.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { updateExtendedMenu(); } }); CheckBox checkBoxEqualizerEnabled = (CheckBox) view.findViewById(R.id.checkBoxEqualizerEnabled); checkBoxEqualizerEnabled.setChecked(musicService.getEqualizerEnabled()); checkBoxEqualizerEnabled.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { musicService.toggleEqualizer(); updateExtendedMenu(); } }); String[] availablePresets = musicService.getEqualizerAvailablePresets(); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, availablePresets); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Spinner spinnerEqualizerPreset = (Spinner) view.findViewById(R.id.spinnerEqualizerPreset); spinnerEqualizerPreset.setAdapter(adapter); spinnerEqualizerPreset.setSelection(musicService.getEqualizerPreset()); spinnerEqualizerPreset.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { musicService.setEqualizerPreset(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); builder.show(); }
From source file:og.android.tether.MainActivity.java
private void openNoNetfilterDialog() { LayoutInflater li = LayoutInflater.from(this); View view = li.inflate(R.layout.nonetfilterview, null); new AlertDialog.Builder(MainActivity.this).setTitle(getString(R.string.main_activity_nonetfilter)) .setView(view)/*from ww w . j a v a2 s . c o m*/ .setNegativeButton(getString(R.string.main_activity_exit), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Log.d(MSG_TAG, "Close pressed"); MainActivity.this.finish(); } }) .setNeutralButton(getString(R.string.main_activity_ignore), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Log.d(MSG_TAG, "Override pressed"); MainActivity.this.application.displayToastMessage( "Ignoring, note that this application will NOT work correctly."); } }).show(); }
From source file:net.networksaremadeofstring.rhybudd.RhybuddHome.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); //Forces our onResume() function to do a DB call rather than a full HTTP request just cos we returned //from one of our subscreens resumeOnResultPollAPI = false;/*from ww w. j av a2 s . c o m*/ BackupManager bm = new BackupManager(this); //Check what the result was from the Settings Activity if (requestCode == 99) { //Refresh the settings settings = PreferenceManager.getDefaultSharedPreferences(this); Intent intent = new Intent(this, ZenossPoller.class); intent.putExtra("settingsUpdate", true); startService(intent); bm.dataChanged(); } else if (requestCode == ZenossAPI.ACTIVITYRESULT_PUSHCONFIG) { if (null != data && data.hasExtra(ZenossAPI.PREFERENCE_PUSHKEY)) { doGCMRegistration(data.getStringExtra(ZenossAPI.PREFERENCE_PUSHKEY)); } } else { //In theory the Settings activity should perform validation and only finish() if the settings pass validation if (resultCode == 1) { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("FirstRun", false); editor.commit(); //Also update our onResume helper bool although it should already be set firstRun = false; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage( "Additional settings and functionality can be found by pressing the action bar overflow (or pressing the menu button).\r\n" + "\r\nPlease note that this is app is still in Beta. If you experience issues please email;\r\nGareth@NetworksAreMadeOfString.co.uk") .setTitle("Welcome to Rhybudd!").setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finishStart(true); } }); AlertDialog welcomeDialog = builder.create(); try { welcomeDialog.show(); } catch (Exception e) { finishStart(true); } bm.dataChanged(); } else if (resultCode == 2) { Toast.makeText(RhybuddHome.this, getResources().getString(R.string.FirstRunNeedSettings), Toast.LENGTH_LONG).show(); finish(); } //Who knows what happened here - quit else { Toast.makeText(RhybuddHome.this, getResources().getString(R.string.FirstRunNeedSettings), Toast.LENGTH_LONG).show(); finish(); } } }
From source file:net.nightwhistler.pageturner.activity.ReadingFragment.java
private void showHighlightEditDialog(final HighLight highLight) { final AlertDialog.Builder editalert = new AlertDialog.Builder(context); editalert.setTitle(R.string.text_note); final EditText input = new EditText(context); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); input.setLayoutParams(lp);/*w w w .j av a 2s.co m*/ editalert.setView(input); input.setText(highLight.getTextNote()); editalert.setPositiveButton(R.string.save_note, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { highLight.setTextNote(input.getText().toString()); bookView.update(); highlightManager.saveHighLights(); } }); editalert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); editalert.setNeutralButton(R.string.clear_note, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { highLight.setTextNote(null); bookView.update(); highlightManager.saveHighLights(); } }); editalert.show(); }
From source file:og.android.tether.MainActivity.java
private void openNoAccessControlDialog() { LayoutInflater li = LayoutInflater.from(this); View view = li.inflate(R.layout.noaccesscontrolview, null); new AlertDialog.Builder(MainActivity.this).setTitle(getString(R.string.main_activity_noaccesscontrol)) .setView(view)// w w w . j av a 2 s .co m .setNeutralButton(getString(R.string.main_activity_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Log.d(MSG_TAG, "OK pressed"); MainActivity.this.application .displayToastMessage(getString(R.string.main_activity_accesscontrol_disabled)); } }).show(); }
From source file:og.android.tether.MainActivity.java
private void openAboutDialog() { LayoutInflater li = LayoutInflater.from(this); View view = li.inflate(R.layout.aboutview, null); TextView versionName = (TextView) view.findViewById(R.id.versionName); versionName.setText(this.application.getVersionName()); new AlertDialog.Builder(MainActivity.this).setTitle(getString(R.string.main_activity_about)).setView(view) .setNeutralButton(getString(R.string.main_activity_donate), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Log.d(MSG_TAG, "Donate pressed"); // Disable donate-dialog for later startups MainActivity.this.application.preferenceEditor.putBoolean("donatepref", false); MainActivity.this.application.preferenceEditor.commit(); Uri uri = Uri.parse(getString(R.string.paypalUrl)); startActivity(new Intent(Intent.ACTION_VIEW, uri)); }// ww w .ja v a 2s .com }) .setNegativeButton(getString(R.string.main_activity_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Log.d(MSG_TAG, "Close pressed"); } }).show(); }
From source file:net.networksaremadeofstring.rhybudd.RhybuddHome.java
public void ManageEvent(final String EventID, final int Position, final int viewID) { AlertDialog.Builder alertbox = new AlertDialog.Builder(this); alertbox.setMessage("What would you like to do?"); alertbox.setPositiveButton("Ack Event", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { AcknowledgeSingleEvent(Position); }// www.j av a 2s. com }); alertbox.setNeutralButton("View Event", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { /*Intent ViewEventIntent = new Intent(RhybuddHome.this, ViewZenossEvent.class); try { ViewEventIntent.putExtra("EventID", EventID); ViewEventIntent.putExtra("Count", listOfZenossEvents.get(Position).getCount()); ViewEventIntent.putExtra("Device", listOfZenossEvents.get(Position).getDevice()); ViewEventIntent.putExtra("EventState", listOfZenossEvents.get(Position).getEventState()); ViewEventIntent.putExtra("FirstTime", listOfZenossEvents.get(Position).getfirstTime()); ViewEventIntent.putExtra("LastTime", listOfZenossEvents.get(Position).getlastTime()); ViewEventIntent.putExtra("Severity", listOfZenossEvents.get(Position).getSeverity()); ViewEventIntent.putExtra("Summary", listOfZenossEvents.get(Position).getSummary()); } catch(Exception e) { } RhybuddHome.this.startActivity(ViewEventIntent);*/ Intent ViewEventIntent = new Intent(RhybuddHome.this, ViewZenossEventActivity.class); ViewEventIntent.putExtra("EventID", EventID); ArrayList<String> EventNames = new ArrayList<String>(); ArrayList<String> EVIDs = new ArrayList<String>(); for (ZenossEvent evt : listOfZenossEvents) { EventNames.add(evt.getDevice()); EVIDs.add(evt.getEVID()); } ViewEventIntent.putStringArrayListExtra("eventnames", EventNames); ViewEventIntent.putStringArrayListExtra("evids", EVIDs); RhybuddHome.this.startActivityForResult(ViewEventIntent, 20); } }); alertbox.setNegativeButton("Nothing", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { } }); alertbox.show(); }
From source file:og.android.tether.MainActivity.java
private void openDonateDialog() { if (this.application.showDonationDialog()) { // Creating Layout LayoutInflater li = LayoutInflater.from(this); View view = li.inflate(R.layout.donateview, null); new AlertDialog.Builder(MainActivity.this).setTitle(getString(R.string.main_activity_donate)) .setView(view).setNeutralButton(getString(R.string.main_activity_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Log.d(MSG_TAG, "Close pressed"); }//from w w w. j a v a 2 s.c o m }) .setNegativeButton(getString(R.string.main_activity_donate), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Log.d(MSG_TAG, "Donate pressed"); // Disable donate-dialog for later startups MainActivity.this.application.preferenceEditor.putBoolean("donatepref", false); MainActivity.this.application.preferenceEditor.commit(); Uri uri = Uri.parse(getString(R.string.paypalUrl)); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } }) .show(); } }
From source file:og.android.tether.MainActivity.java
public void openUpdateDialog(final String downloadFileUrl, final String fileName, final String message, final String updateTitle) { LayoutInflater li = LayoutInflater.from(this); Builder dialog;/*from ww w . j a va 2 s . c o m*/ View view; view = li.inflate(R.layout.updateview, null); TextView messageView = (TextView) view.findViewById(R.id.updateMessage); TextView updateNowText = (TextView) view.findViewById(R.id.updateNowText); if (fileName.length() == 0) // No filename, hide 'download now?' string updateNowText.setVisibility(View.GONE); messageView.setText(message); dialog = new AlertDialog.Builder(MainActivity.this).setTitle(updateTitle).setView(view); if (fileName.length() > 0) { // Display Yes/No for if a filename is available. dialog.setNeutralButton(getString(R.string.main_activity_no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Log.d(MSG_TAG, "No pressed"); } }); dialog.setNegativeButton(getString(R.string.main_activity_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Log.d(MSG_TAG, "Yes pressed"); MainActivity.this.application.downloadUpdate(downloadFileUrl, fileName); } }); } else dialog.setNeutralButton(getString(R.string.main_activity_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Log.d(MSG_TAG, "Ok pressed"); } }); dialog.show(); }
From source file:com.daiv.android.twitter.ui.drawer_activities.DrawerActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { try {/*from w ww . j av a2 s.com*/ if (mDrawerToggle.onOptionsItemSelected(item)) { if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) { mDrawerLayout.closeDrawer(Gravity.RIGHT); } return true; } } catch (Exception e) { // landscape } switch (item.getItemId()) { case R.id.menu_search: overridePendingTransition(0, 0); finish(); overridePendingTransition(0, 0); return super.onOptionsItemSelected(item); case R.id.menu_compose: Intent compose = new Intent(context, ComposeActivity.class); sharedPrefs.edit().putBoolean("from_notification_bool", false).commit(); startActivity(compose); return super.onOptionsItemSelected(item); case R.id.menu_settings: context.sendBroadcast(new Intent("com.daiv.android.twitter.MARK_POSITION")); finish(); sharedPrefs.edit().putBoolean("should_refresh", false).commit(); overridePendingTransition(R.anim.slide_in_left, R.anim.activity_zoom_exit); return super.onOptionsItemSelected(item); case R.id.menu_dismiss: InteractionsDataSource data = InteractionsDataSource.getInstance(context); data.markAllRead(DrawerActivity.settings.currentAccount); mDrawerLayout.closeDrawer(Gravity.RIGHT); notificationAdapter = new InteractionsCursorAdapter(context, data.getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); return super.onOptionsItemSelected(item); case R.id.menu_notifications: if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) { mDrawerLayout.closeDrawer(Gravity.LEFT); } if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) { mDrawerLayout.closeDrawer(Gravity.RIGHT); } else { mDrawerLayout.openDrawer(Gravity.RIGHT); } return super.onOptionsItemSelected(item); case R.id.menu_to_first: context.sendBroadcast(new Intent("com.daiv.android.twitter.TOP_TIMELINE")); return super.onOptionsItemSelected(item); case R.id.menu_tweetmarker: context.sendBroadcast(new Intent("com.daiv.android.twitter.TWEETMARKER")); return super.onOptionsItemSelected(item); case R.id.menu_get_help: new AlertDialog.Builder(context).setTitle(R.string.faq).setMessage(R.string.faq_first) .setPositiveButton("FAQ", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { XmlFaqUtils.showFaqDialog(context); } }).setNegativeButton(R.string.contact, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showContactUsDialog(); } }).setNeutralButton(R.string.follow, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { showFollowDialog(); } }).create().show(); return super.onOptionsItemSelected(item); default: return super.onOptionsItemSelected(item); } }