Java Code Examples for android.app.AlertDialog.setView()

The following are Jave code examples for showing how to use setView() of the android.app.AlertDialog class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: editor   File: Editor.java   Source Code and License Vote up 6 votes
private void saveAsDialog(int title, int message, String path,
                          DialogInterface.OnClickListener listener)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(title);
    builder.setMessage(message);

    // Add the buttons
    builder.setPositiveButton(R.string.save, listener);
    builder.setNegativeButton(R.string.cancel, listener);

    // Create edit text
    Context context = builder.getContext();
    EditText text = new EditText(context);
    text.setId(TEXT);
    text.setText(path);

    // Create the AlertDialog
    AlertDialog dialog = builder.create();
    dialog.setView(text, 30, 0, 30, 0);
    dialog.show();
}
 
Example 2
Project: ulogger-android   File: Alert.java   Source Code and License Vote up 5 votes
/**
 * Show dialog
 * @param context Context
 * @param title Title
 * @param layoutResource Layout resource id
 * @param iconResource Icon resource id
 * @return AlertDialog Dialog
 */
static AlertDialog showAlert(Context context, CharSequence title, int layoutResource, int iconResource) {
    @SuppressLint("InflateParams")
    View view = ((Activity) context).getLayoutInflater().inflate(layoutResource, null, false);
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setView(view);
    if (iconResource > 0) {
        alertDialog.setIcon(iconResource);
    }
    alertDialog.show();
    return alertDialog;
}