Example usage for android.app AlertDialog setTitle

List of usage examples for android.app AlertDialog setTitle

Introduction

In this page you can find the example usage for android.app AlertDialog setTitle.

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public void promptMultiAIO(final Activity activity) {
    // if (!ICS) {
    // Toast.makeText(getApplicationContext(),
    // "Multithread AIO supported only for ICS and above!",
    // Toast.LENGTH_SHORT).show();
    // this.mMultiAIO.setChecked(false);
    // return;//from www.ja  v a 2 s  .c o m
    // }
    final AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle("Warning!");
    TextView info = new TextView(activity);
    info.setText("Enabling Multithreaded AIO might speed up I/O in the VM "
            + "but it might not work for all devices. "
            + "Multithreaded AIO is experimental and might damage any disk image you open with Limbo so keep a "
            + "backup of your images if you're not certain. "
            + "If you see errors uncheck this option and try again.");
    alertDialog.setView(info);
    final Handler handler = this.handler;
    alertDialog.setButton("Set", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            LimboSettingsManager.setMultiAIO(activity, true);

        }
    });
    alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            mMultiAIO.setChecked(false);
            LimboSettingsManager.setMultiAIO(activity, false);
            return;
        }
    });
    alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            mMultiAIO.setChecked(false);
            LimboSettingsManager.setMultiAIO(activity, false);
        }
    });
    alertDialog.show();

}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

private void promptImportMachines() {
    // TODO Auto-generated method stub

    final AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle("Import Machines");

    RelativeLayout mLayout = new RelativeLayout(this);
    mLayout.setId(12222);/*from w  w  w  .  j a v a2s.  c  o  m*/

    TextView imageNameView = new TextView(activity);
    imageNameView.setVisibility(View.VISIBLE);
    imageNameView.setId(201012010);
    imageNameView.setText(
            "Step 1: Place the machine.CSV file you export previously under \"limbo\" directory in your SD card.\n"
                    + "Step 2: WARNING: Any machine with the same name will be replaced!\n"
                    + "Step 3: Press \"OK\".\n");

    RelativeLayout.LayoutParams searchViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    mLayout.addView(imageNameView, searchViewParams);
    alertDialog.setView(mLayout);

    final Handler handler = this.handler;

    // alertDialog.setMessage(body);
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // For each line create a Machine
            progDialog = ProgressDialog.show(activity, "Please Wait", "Importing Machines...", true);

            ImportMachines importer = new ImportMachines();
            importer.execute();
        }
    });
    alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            return;
        }
    });
    alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {

            return;

        }
    });
    alertDialog.show();

}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public void promptVNCAllowExternal(final Activity activity) {
    final AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle("Enable VNC server");

    TextView textView = new TextView(activity);
    textView.setVisibility(View.VISIBLE);
    textView.setId(201012010);/* ww  w  .  j a  v  a  2s . c o m*/
    textView.setText("VNC Server: " + this.getLocalIpAddress() + ":" + "5901\n"
            + "Warning: VNC is not secure make sure you're on a private network!\n");

    EditText passwdView = new EditText(activity);
    passwdView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    passwdView.setHint("Password");
    passwdView.setEnabled(true);
    passwdView.setVisibility(View.VISIBLE);
    passwdView.setId(11111);
    passwdView.setSingleLine();

    RelativeLayout mLayout = new RelativeLayout(this);
    mLayout.setId(12222);

    RelativeLayout.LayoutParams textViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    textViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, mLayout.getId());
    mLayout.addView(textView, textViewParams);

    RelativeLayout.LayoutParams passwordViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    passwordViewParams.addRule(RelativeLayout.BELOW, textView.getId());
    // passwordViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,
    // mLayout.getId());
    mLayout.addView(passwdView, passwordViewParams);

    alertDialog.setView(mLayout);

    final Handler handler = this.handler;

    alertDialog.setButton("Set", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            // UIUtils.log("Searching...");
            EditText a = (EditText) alertDialog.findViewById(11111);

            if (a.getText().toString().trim().equals("")) {
                Toast.makeText(getApplicationContext(), "Password cannot be empty!", Toast.LENGTH_SHORT).show();
                vnc_passwd = null;
                vnc_allow_external = 0;
                mVNCAllowExternal.setChecked(false);
                // LimboSettingsManager.setVNCAllowExternal(activity, false);
                return;
            } else {
                sendHandlerMessage(handler, Const.VNC_PASSWORD, "vnc_passwd", "passwd");
                vnc_passwd = a.getText().toString();
                vnc_allow_external = 1;
                // LimboSettingsManager.setVNCAllowExternal(activity, true);
            }

        }
    });
    alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            vnc_passwd = null;
            vnc_allow_external = 0;
            mVNCAllowExternal.setChecked(false);
            // LimboSettingsManager.setVNCAllowExternal(activity, false);
            return;
        }
    });
    alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            mVNCAllowExternal.setChecked(false);
            // LimboSettingsManager.setVNCAllowExternal(activity, false);
            vnc_passwd = null;
            vnc_allow_external = 0;
        }
    });
    alertDialog.show();

}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public void promptImageName(final Activity activity, String hd) {
    final String hd_string = hd;
    final AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle("Image Name");

    RelativeLayout mLayout = new RelativeLayout(this);
    mLayout.setId(12222);/* ww w .  j  a v  a2  s  .  c  o m*/

    EditText imageNameView = new EditText(activity);
    imageNameView.setEnabled(true);
    imageNameView.setVisibility(View.VISIBLE);
    imageNameView.setId(201012010);
    imageNameView.setSingleLine();
    RelativeLayout.LayoutParams searchViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    mLayout.addView(imageNameView, searchViewParams);

    final Spinner size = new Spinner(this);
    RelativeLayout.LayoutParams setPlusParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    size.setId(201012044);

    String[] arraySpinner = new String[7];
    for (int i = 0; i < arraySpinner.length; i++) {

        if (i < 5) {
            arraySpinner[i] = (i + 1) + " GB";
        }

    }
    arraySpinner[5] = "10 GB";
    arraySpinner[6] = "20 GB";

    ArrayAdapter sizeAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner);
    sizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    size.setAdapter(sizeAdapter);
    setPlusParams.addRule(RelativeLayout.BELOW, imageNameView.getId());
    mLayout.addView(size, setPlusParams);

    // TODO: Not working for now
    // final TextView preallocText = new TextView(this);
    // preallocText.setText("Preallocate? ");
    // preallocText.setTextSize(15);
    // RelativeLayout.LayoutParams preallocTParams = new
    // RelativeLayout.LayoutParams(
    // RelativeLayout.LayoutParams.WRAP_CONTENT,
    // RelativeLayout.LayoutParams.WRAP_CONTENT);
    // preallocTParams.addRule(RelativeLayout.BELOW, size.getId());
    // mLayout.addView(preallocText, preallocTParams);
    // preallocText.setId(64512044);
    //
    // final CheckBox prealloc = new CheckBox(this);
    // RelativeLayout.LayoutParams preallocParams = new
    // RelativeLayout.LayoutParams(
    // RelativeLayout.LayoutParams.WRAP_CONTENT,
    // RelativeLayout.LayoutParams.WRAP_CONTENT);
    // preallocParams.addRule(RelativeLayout.BELOW, size.getId());
    // preallocParams.addRule(RelativeLayout.RIGHT_OF,
    // preallocText.getId());
    // preallocParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,
    // preallocText.getId());
    // mLayout.addView(prealloc, preallocParams);
    // prealloc.setId(64512344);

    alertDialog.setView(mLayout);

    final Handler handler = this.handler;

    // alertDialog.setMessage(body);
    alertDialog.setButton("Create", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            int sizeSel = size.getSelectedItemPosition();
            String templateImage = "hd1g.qcow2";
            if (sizeSel < 5) {
                templateImage = "hd" + (sizeSel + 1) + "g.qcow2";
            } else if (sizeSel == 5) {
                templateImage = "hd10g.qcow2";
            } else if (sizeSel == 6) {
                templateImage = "hd20g.qcow2";
            }

            // UIUtils.log("Searching...");
            EditText a = (EditText) alertDialog.findViewById(201012010);
            progDialog = ProgressDialog.show(activity, "Please Wait", "Creating HD Image...", true);
            // CreateImage createImg = new
            // CreateImage(a.getText().toString(),
            // hd_string, sizeInt, prealloc.isChecked());
            //            CreateImage createImg = new CreateImage(a.getText().toString(),
            //                  hd_string, sizeInt, false);
            //            createImg.execute();

            String image = a.getText().toString();
            if (!image.endsWith(".qcow2")) {
                image += ".qcow2";
            }
            createImg(templateImage, image, hd_string);

        }
    });
    alertDialog.show();

}

From source file:self.philbrown.droidQuery.$.java

/**
 * Show an alert// w  w w . j  a  v  a2s . c  om
 * @param context used to display the alert window
 * @param title the title of the alert window. Use {@code null} to show no title
 * @param text the alert message
 * @see #alert(Context, String)
 */
public static void alert(Context context, String title, String text) {
    AlertDialog alert = new AlertDialog.Builder(context).create();
    alert.setTitle(title);
    alert.setMessage(text);
    alert.setButton("OK", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }

    });
    alert.show();
}

From source file:self.philbrown.droidQuery.$.java

/**
 * Uses the current context to show an alert dialog.
 * @param title the alert title// w ww .  jav  a2 s . co m
 * @param text the alert message.
 * @see #alert(String)
 */
public void alert(String title, String text) {
    AlertDialog alert = new AlertDialog.Builder(context).create();
    alert.setTitle(title);
    alert.setMessage(text);
    alert.setButton("OK", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }

    });
    alert.show();
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

/**
 * ADW: Put the launcher in desktop edit mode We could be able to add,
 * remove and reorder screens//from   ww w.  j a v  a2 s .c  o  m
 */
private void startDesktopEdit() {
    if (!mIsEditMode) {
        mIsEditMode = true;
        final PersonaWorkspace personaWorkspace = mWorkspace;
        if (personaWorkspace == null)
            return;
        personaWorkspace.enableChildrenCache(0, personaWorkspace.getChildCount());
        hideDesktop(true);
        personaWorkspace.lock();
        // Load a gallery view
        final PersonaScreensAdapter screens = new PersonaScreensAdapter(this,
                personaWorkspace.getChildAt(0).getWidth(), personaWorkspace.getChildAt(0).getHeight());
        for (int i = 0; i < personaWorkspace.getChildCount(); i++) {
            screens.addScreen((PersonaCellLayout) personaWorkspace.getChildAt(i));
        }
        mScreensEditor = mInflater.inflate(R.layout.pr_screens_editor, null);
        final Gallery gal = (Gallery) mScreensEditor.findViewById(R.id.gallery_screens);
        gal.setCallbackDuringFling(false);
        gal.setClickable(false);
        gal.setAdapter(screens);
        // Setup delete button event
        View deleteButton = mScreensEditor.findViewById(R.id.delete_screen);
        deleteButton.setOnClickListener(new android.view.View.OnClickListener() {
            public void onClick(View v) {
                final int screenToDelete = gal.getSelectedItemPosition();
                if (personaWorkspace.getChildCount() > 1) {
                    AlertDialog alertDialog = new AlertDialog.Builder(PersonaLauncher.this).create();
                    alertDialog.setTitle(getResources().getString(R.string.title_dialog_xml));
                    alertDialog.setMessage(getResources().getString(R.string.message_delete_desktop_screen));
                    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,
                            getResources().getString(android.R.string.ok),
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    personaWorkspace.removeScreen(screenToDelete);
                                    screens.removeScreen(screenToDelete);
                                }
                            });
                    alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
                            getResources().getString(android.R.string.cancel),
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                }
                            });
                    alertDialog.show();
                } else {
                    Toast t = Toast.makeText(PersonaLauncher.this,
                            R.string.message_cannot_delete_desktop_screen, Toast.LENGTH_LONG);
                    t.show();
                }

            }
        });
        // Setup add buttons events
        View addLeftButton = mScreensEditor.findViewById(R.id.add_left);
        addLeftButton.setOnClickListener(new android.view.View.OnClickListener() {
            public void onClick(View v) {
                if (screens.getCount() < MAX_SCREENS) {
                    final int screenToAddLeft = gal.getSelectedItemPosition();
                    PersonaCellLayout newScreen = personaWorkspace.addScreen(screenToAddLeft);
                    screens.addScreen(newScreen, screenToAddLeft);
                } else {
                    Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_add_desktop_screen,
                            Toast.LENGTH_LONG);
                    t.show();
                }
            }
        });
        View addRightButton = mScreensEditor.findViewById(R.id.add_right);
        addRightButton.setOnClickListener(new android.view.View.OnClickListener() {
            public void onClick(View v) {
                if (screens.getCount() < MAX_SCREENS) {
                    final int screenToAddRight = gal.getSelectedItemPosition();
                    PersonaCellLayout newScreen = personaWorkspace.addScreen(screenToAddRight + 1);
                    screens.addScreen(newScreen, screenToAddRight + 1);
                } else {
                    Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_add_desktop_screen,
                            Toast.LENGTH_LONG);
                    t.show();
                }
            }
        });

        final View swapLeftButton = mScreensEditor.findViewById(R.id.swap_left);
        swapLeftButton.setOnClickListener(new android.view.View.OnClickListener() {
            public void onClick(View v) {
                int currentScreen = gal.getSelectedItemPosition();
                if (currentScreen > 0) {
                    personaWorkspace.swapScreens(currentScreen - 1, currentScreen);
                    screens.swapScreens(currentScreen - 1, currentScreen);
                } else {
                    Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_swap_desktop_screen,
                            Toast.LENGTH_LONG);
                    t.show();
                }
            }
        });
        final View swapRightButton = mScreensEditor.findViewById(R.id.swap_right);
        swapRightButton.setOnClickListener(new android.view.View.OnClickListener() {
            public void onClick(View v) {
                int currentScreen = gal.getSelectedItemPosition();
                if (currentScreen < gal.getCount() - 1) {
                    personaWorkspace.swapScreens(currentScreen, currentScreen + 1);
                    screens.swapScreens(currentScreen, currentScreen + 1);
                } else {
                    Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_swap_desktop_screen,
                            Toast.LENGTH_LONG);
                    t.show();
                }
            }
        });
        final View setDefaultButton = mScreensEditor.findViewById(R.id.set_default);
        setDefaultButton.setOnClickListener(new android.view.View.OnClickListener() {
            public void onClick(View v) {
                int currentScreen = gal.getSelectedItemPosition();
                if (currentScreen < mWorkspace.getChildCount()) {
                    mWorkspace.setDefaultScreen(currentScreen);
                    PersonaAlmostNexusSettingsHelper.setDefaultScreen(PersonaLauncher.this, currentScreen);
                    Toast t = Toast.makeText(PersonaLauncher.this, R.string.pref_title_default_screen,
                            Toast.LENGTH_LONG);
                    t.show();
                }
            }
        });
        gal.setOnItemSelectedListener(new OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                if (position <= 0) {
                    swapLeftButton.setVisibility(View.GONE);
                } else {
                    swapLeftButton.setVisibility(View.VISIBLE);
                }
                if (position < parent.getCount() - 1) {
                    swapRightButton.setVisibility(View.VISIBLE);
                } else {
                    swapRightButton.setVisibility(View.GONE);
                }
            }

            public void onNothingSelected(AdapterView<?> arg0) {
            }

        });
        mDragLayer.addView(mScreensEditor);
    }
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

@SuppressWarnings("unused")
void addSearch() {
    final PersonaWidget info = PersonaWidget.makeSearch();
    final PersonaCellLayout.CellInfo cellInfo = mAddItemCellInfo;

    final int[] xy = mCellCoordinates;
    final int spanX = info.spanX;
    final int spanY = info.spanY;

    AlertDialog.Builder builder;//from  w  w  w  .  j  a v a 2 s . c  o m
    AlertDialog alertDialog;

    final View dlg_layout = View.inflate(PersonaLauncher.this, R.layout.pr_widget_span_setup, null);
    final PersonaNumberPicker ncols = (PersonaNumberPicker) dlg_layout.findViewById(R.id.widget_columns_span);
    ncols.setRange(1, mWorkspace.currentDesktopColumns());
    ncols.setCurrent(spanX);
    final PersonaNumberPicker nrows = (PersonaNumberPicker) dlg_layout.findViewById(R.id.widget_rows_span);
    nrows.setRange(1, mWorkspace.currentDesktopRows());
    nrows.setCurrent(spanY);
    builder = new AlertDialog.Builder(PersonaLauncher.this);
    builder.setView(dlg_layout);
    alertDialog = builder.create();
    alertDialog.setTitle(getResources().getString(R.string.widget_config_dialog_title));
    alertDialog.setMessage(getResources().getString(R.string.widget_config_dialog_summary));
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    int spanX = ncols.getCurrent();
                    int spanY = nrows.getCurrent();
                    // realAddSearch(info,cellInfo,xy,spanX,spanY);
                }
            });
    alertDialog.show();
}