Created
August 16, 2013 16:11
-
-
Save YvesBill/6251242 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| @Override | |
| public boolean onOptionsItemSelected(MenuItem item) { | |
| switch (item.getItemId()) { | |
| case R.id.alert: | |
| alert(); | |
| return true; | |
| default: | |
| return super.onOptionsItemSelected(item); | |
| } | |
| } | |
| private void alert() { | |
| AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); | |
| // settare il titolo | |
| alertDialogBuilder.setTitle("Title"); | |
| alertDialogBuilder.setIcon(R.drawable.ic_launcher); | |
| // settare il messaggio | |
| alertDialogBuilder | |
| .setMessage("Message") | |
| .setCancelable(false) | |
| .setPositiveButton("Yes",new DialogInterface.OnClickListener() { | |
| public void onClick(DialogInterface dialog,int id) { | |
| // Intento, in questo caso apre una applicazione ma potrebbe essere una classe o altro | |
| Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); | |
| myWebLink.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.Lunar.HD")); | |
| startActivity(myWebLink); | |
| } | |
| }) | |
| .setNegativeButton("No",new DialogInterface.OnClickListener() { | |
| public void onClick(DialogInterface dialog,int id) { | |
| // close AlertDialog | |
| dialog.cancel(); | |
| Toast.makeText(getApplicationContext(), | |
| "Close", Toast.LENGTH_LONG).show(); | |
| } | |
| }); | |
| // create alert dialog | |
| AlertDialog alertDialog = alertDialogBuilder.create(); | |
| // show it | |
| alertDialog.show(); | |
| ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment