import android.support.v7.app.AlertDialog AlertDialog.Builder builder = new AlertDialog.Builder(this);
import android.support.v7.app.AlertDialog AlertDialog.Builder builder = new AlertDialog.Builder(this);
AlertDialog.Builder alert = new AlertDialog.Builder(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom));
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setPositiveButton(android.R.string.ok, null); AlertDialog dialog = builder.create(); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { if(condition) ((AlertDialog)dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); } }); dialog.show();
private CharSequence[] items = {"Set as Ringtone", "Set as Alarm"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if(item == 0) { } else if(item == 1) { } else if(item == 2) { } } }); AlertDialog dialog = builder.create(); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes(); wmlp.gravity = Gravity.TOP | Gravity.LEFT; wmlp.x = 100; //x position wmlp.y = 100; //y position dialog.show();
final CharSequence[] items = {"Red", "Green", "Blue"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Pick a color"); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); } }); AlertDialog alert = builder.create(); alert.show();
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Look at this dialog!") .setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //do things } }); AlertDialog alert = builder.create(); alert.show();
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(false);
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(layout); builder.setTitle("Title"); alertDialog = builder.create(); alertDialog.show(); alertDialog.getWindow().setLayout(600, 400); //Controlling width and height.
LayoutInflater inflater = getLayoutInflater(); View dialoglayout = inflater.inflate(R.layout.dialog_layout, null); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(dialoglayout); builder.show();
CharSequence colors[] = new CharSequence[] {"red", "green", "blue", "black"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Pick a color"); builder.setItems(colors, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // the user clicked on colors[which] } }); builder.show();
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Title"); builder.setMessage("Message"); builder.setPositiveButton("OK", null); AlertDialog dialog = builder.show(); // Must call show() prior to fetching text view TextView messageView = (TextView)dialog.findViewById(android.R.id.message); messageView.setGravity(Gravity.CENTER);
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Title"); // Set up the input final EditText input = new EditText(this); // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); builder.setView(input); // Set up the buttons builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { m_Text = input.getText().toString(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show();
AlertDialog.Builder b = new AlertDialog.Builder(this);//.... AlertDialog dialog = b.create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); dialog.show();
final CharSequence[] items = {"Foo", "Bar", "Baz"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Make your selection"); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { // Do something with the selection } }); AlertDialog alert = builder.create(); alert.show();
AlertDialog.Builder builder = new AlertDialog.Builder(); AlertDialog dialog; builder.set... dialog = builder.create(); dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); dialog.show();