List of usage examples for android.app AlertDialog setView
public void setView(View view)
From source file:com.haibison.android.anhuu.FragmentFiles.java
/** * Confirms user to create new directory. *//*from w w w . j a va 2 s . co m*/ private void showNewDirectoryCreationDialog() { final AlertDialog dialog = Dlg.newAlertDlg(getActivity()); View view = getLayoutInflater(null).inflate(R.layout.anhuu_f5be488d_simple_text_input_view, null); final EditText textFile = (EditText) view.findViewById(R.id.anhuu_f5be488d_text1); textFile.setHint(R.string.anhuu_f5be488d_hint_folder_name); textFile.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { UI.showSoftKeyboard(v, false); dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick(); return true; } return false; } }); dialog.setView(view); dialog.setTitle(R.string.anhuu_f5be488d_cmd_new_folder); dialog.setIcon(android.R.drawable.ic_menu_add); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final String name = textFile.getText().toString().trim(); if (!FileUtils.isFilenameValid(name)) { Dlg.toast(getActivity(), getString(R.string.anhuu_f5be488d_pmsg_filename_is_invalid, name), Dlg.LENGTH_SHORT); return; } new LoadingDialog<Void, Void, Uri>(getActivity(), false) { @Override protected Uri doInBackground(Void... params) { return getActivity().getContentResolver().insert( BaseFile.genContentUriBase(getCurrentLocation().getAuthority()).buildUpon() .appendPath(getCurrentLocation().getLastPathSegment()) .appendQueryParameter(BaseFile.PARAM_NAME, name) .appendQueryParameter(BaseFile.PARAM_FILE_TYPE, Integer.toString(BaseFile.FILE_TYPE_DIRECTORY)) .build(), null); }// doInBackground() @Override protected void onPostExecute(Uri result) { super.onPostExecute(result); if (result != null) { Dlg.toast(getActivity(), getString(R.string.anhuu_f5be488d_msg_done), Dlg.LENGTH_SHORT); } else Dlg.toast(getActivity(), getString(R.string.anhuu_f5be488d_pmsg_cannot_create_folder, name), Dlg.LENGTH_SHORT); }// onPostExecute() }.execute(); }// onClick() }); dialog.show(); UI.showSoftKeyboard(textFile, true); final Button buttonOk = dialog.getButton(DialogInterface.BUTTON_POSITIVE); buttonOk.setEnabled(false); textFile.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { /* * Do nothing. */ }// onTextChanged() @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { /* * Do nothing. */ }// beforeTextChanged() @Override public void afterTextChanged(Editable s) { buttonOk.setEnabled(FileUtils.isFilenameValid(s.toString().trim())); }// afterTextChanged() }); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptMachineName(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Machine Name"); EditText searchView = new EditText(activity); searchView.setEnabled(true);//w w w .j a v a 2 s . c om searchView.setVisibility(View.VISIBLE); searchView.setId(201012010); searchView.setSingleLine(); alertDialog.setView(searchView); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); sendHandlerMessage(handler, Const.VM_CREATED, "machine_name", a.getText().toString()); return; } }); alertDialog.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptStateName(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Snapshot/State Name"); EditText searchView = new EditText(activity); searchView.setEnabled(true);//from www . j ava 2 s . com searchView.setVisibility(View.VISIBLE); searchView.setId(201012010); searchView.setSingleLine(); alertDialog.setView(searchView); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); sendHandlerMessage(handler, Const.SNAPSHOT_CREATED, new String[] { "snapshot_name" }, new String[] { a.getText().toString() }); return; } }); alertDialog.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private void promptPrio(final Activity activity) { // TODO Auto-generated method stub final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Enable High Priority!"); TextView textView = new TextView(activity); textView.setVisibility(View.VISIBLE); textView.setId(201012010);/*from w ww .j ava 2 s .co m*/ textView.setText( "Warning! High Priority might increase emulation speed but " + "will slow your phone down!"); alertDialog.setView(textView); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { LimboSettingsManager.setPrio(activity, true); } }); alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mPrio.setChecked(false); return; } }); alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mPrio.setChecked(false); } }); alertDialog.show(); }
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;/*ww w. j a v a 2s. c om*/ // } 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. ja va2s . co 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);/* w w w . j av a 2 s . 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);/*from www. 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(); }