List of usage examples for android.widget EditText EditText
public EditText(Context context)
From source file:com.zbrown.droidsteal.activities.HijackActivity.java
private void selectURL() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(getString(R.string.changeurl)); alert.setMessage(getString(R.string.customurl)); // Set an EditText view to get user input final EditText inputName = new EditText(this); inputName.setText(HijackActivity.this.webview.getUrl()); alert.setView(inputName);/*from w ww. j a v a 2 s . co m*/ alert.setPositiveButton("Go", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { HijackActivity.this.webview.loadUrl(inputName.getText().toString()); } }); alert.show(); }
From source file:com.loloof64.android.capturing_audio.MainActivity.java
public void purposeFileRenaming(final File externalStorageDir, final File tempAudioFile, final Calendar captureStartDate) { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); dialogBuilder.setTitle(R.string.renaming_temporary_file); final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.HORIZONTAL); final TextView label = new TextView(this); label.setText(R.string.defining_file_name_label); layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); final EditText input = new EditText(this); input.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); input.setInputType(InputType.TYPE_CLASS_TEXT); layout.addView(label);// w w w .j av a2 s. c om layout.addView(input); dialogBuilder.setView(layout); dialogBuilder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String defaultNameRadix = new SimpleDateFormat(DEFAULT_FILE_NAME_FORMAT, Locale.getDefault()) .format(captureStartDate.getTime()); String nameRadix = input.getText().toString(); if (nameRadix.isEmpty()) { nameRadix = defaultNameRadix; } // Append a number to the name radix if necessary File testedFile = new File(externalStorageDir, String.format(FINAL_FILE_NAME_FORMAT, nameRadix)); boolean fileNameAlreadyUsed = testedFile.exists(); if (fileNameAlreadyUsed) { int number = 1; String chosenNameRadix; while (true) { chosenNameRadix = String.format(Locale.getDefault(), "%s%d", nameRadix, number); testedFile = new File(externalStorageDir, String.format(FINAL_FILE_NAME_FORMAT, chosenNameRadix)); fileNameAlreadyUsed = testedFile.exists(); if (!fileNameAlreadyUsed) break; number++; } nameRadix = chosenNameRadix; } String fileName = String.format(FINAL_FILE_NAME_FORMAT, nameRadix); File newFile = new File(externalStorageDir, fileName); boolean renameSuccess = tempAudioFile.renameTo(newFile); if (renameSuccess) { Toast.makeText(MainActivity.this, R.string.renamed_file, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(MainActivity.this, R.string.file_renaming_failure, Toast.LENGTH_SHORT).show(); } } }); dialogBuilder.show(); }
From source file:com.newtifry.android.SourceList.java
/** * Helper function to show a dialog to ask for a source name. *//*from w w w . j a va 2 s . c o m*/ private void askForSourceName() { final EditText input = new EditText(this); new AlertDialog.Builder(this).setTitle(getString(R.string.create_source)) .setMessage(getString(R.string.create_source_message)).setView(input) .setPositiveButton(getString(R.string.create), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Editable value = input.getText(); if (value.length() > 0) { // Fire it off to the create source function. createSource(value.toString()); } } }).setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // No need to take any action. } }).show(); }
From source file:com.mediaexplorer.remote.MexRemoteActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/* ww w .j a va2 s .c o m*/ this.setTitle(R.string.app_name); dbg = "MexWebremote"; text_view = (TextView) findViewById(R.id.text); web_view = (WebView) findViewById(R.id.link_view); web_view.getSettings().setJavaScriptEnabled(true);/* /* Future: setOverScrollMode is API level >8 * web_view.setOverScrollMode (OVER_SCROLL_NEVER); */ web_view.setBackgroundColor(0); web_view.setWebViewClient(new WebViewClient() { /* for some reason we only get critical errors so an auth error * is not handled here which is why there is some crack that test * the connection with a special httpclient */ @Override public void onReceivedHttpAuthRequest(final WebView view, final HttpAuthHandler handler, final String host, final String realm) { String[] userpass = new String[2]; userpass = view.getHttpAuthUsernamePassword(host, realm); HttpResponse response = null; HttpGet httpget; DefaultHttpClient httpclient; String target_host; int target_port; target_host = MexRemoteActivity.this.target_host; target_port = MexRemoteActivity.this.target_port; /* We may get null from getHttpAuthUsernamePassword which will * break the setCredentials so junk used instead to keep * it happy. */ Log.d(dbg, "using the set httpauth, testing auth using client"); try { if (userpass == null) { userpass = new String[2]; userpass[0] = "none"; userpass[1] = "none"; } } catch (Exception e) { userpass = new String[2]; userpass[0] = "none"; userpass[1] = "none"; } /* Log.d ("debug", * "trying: GET http://"+userpass[0]+":"+userpass[1]+"@"+target_host+":"+target_port+"/"); */ /* We're going to test the authentication credentials that we * have before using them so that we can act on the response. */ httpclient = new DefaultHttpClient(); httpget = new HttpGet("http://" + target_host + ":" + target_port + "/"); httpclient.getCredentialsProvider().setCredentials(new AuthScope(target_host, target_port), new UsernamePasswordCredentials(userpass[0], userpass[1])); try { response = httpclient.execute(httpget); } catch (IOException e) { Log.d(dbg, "Problem executing the http get"); e.printStackTrace(); } Log.d(dbg, "HTTP reponse:" + Integer.toString(response.getStatusLine().getStatusCode())); if (response.getStatusLine().getStatusCode() == 401) { /* We got Authentication failed (401) so ask user for u/p */ /* login dialog box */ final AlertDialog.Builder logindialog; final EditText user; final EditText pass; LinearLayout layout; LayoutParams params; TextView label_username; TextView label_password; logindialog = new AlertDialog.Builder(MexRemoteActivity.this); logindialog.setTitle("Mex Webremote login"); user = new EditText(MexRemoteActivity.this); pass = new EditText(MexRemoteActivity.this); layout = new LinearLayout(MexRemoteActivity.this); pass.setTransformationMethod(new PasswordTransformationMethod()); layout.setOrientation(LinearLayout.VERTICAL); params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layout.setLayoutParams(params); user.setLayoutParams(params); pass.setLayoutParams(params); label_username = new TextView(MexRemoteActivity.this); label_password = new TextView(MexRemoteActivity.this); label_username.setText("Username:"); label_password.setText("Password:"); layout.addView(label_username); layout.addView(user); layout.addView(label_password); layout.addView(pass); logindialog.setView(layout); logindialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); logindialog.setPositiveButton("Login", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String uvalue = user.getText().toString().trim(); String pvalue = pass.getText().toString().trim(); view.setHttpAuthUsernamePassword(host, realm, uvalue, pvalue); handler.proceed(uvalue, pvalue); } }); logindialog.show(); /* End login dialog box */ } else /* We didn't get a 401 */ { handler.proceed(userpass[0], userpass[1]); } } /* End onReceivedHttpAuthRequest */ }); /* End Override */ /* Run mdns to check for service in a "runnable" (async) */ handler.post(new Runnable() { public void run() { startMdns(); } }); dialog = ProgressDialog.show(MexRemoteActivity.this, "", "Searching...", true); /* Let's put something in the webview while we're waiting */ String summary = "<html><head><style>body { background-color: #000000; color: #ffffff; }></style></head><body><p>Searching for the media explorer webservice</p><p>More infomation on <a href=\"http://media-explorer.github.com\" >Media Explorer's home page</a></p></body></html>"; web_view.loadData(summary, "text/html", "utf-8"); }
From source file:com.example.dell.chihuobao.fragment.SettingFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { hashMap = user.getUser();//from w w w. jav a2s .c o m View view = inflater.inflate(R.layout.setting, container, false); restaurant_icon = (ImageView) view.findViewById(R.id.restaurant_icon); tv_restaurant_name = (TextView) view.findViewById(R.id.tv_restaurant_name); tv_owner_phone = (TextView) view.findViewById(R.id.tv_owner_phone); tv_owner_cardnumber = (TextView) view.findViewById(R.id.tv_owner_cardnumber); shopmessage = (TextView) view.findViewById(R.id.shopmessage); if (MyApplication.getUser().getUser().get("name") != null) { tv_restaurant_name.setText(MyApplication.getUser().getUser().get("name").toString()); } if (MyApplication.getUser().getUser().get("phone") != null) { tv_owner_phone.setText(MyApplication.getUser().getUser().get("phone").toString()); } if (MyApplication.getUser().getUser().get("identify") != null) { tv_owner_cardnumber .setText(getDisplayStr(MyApplication.getUser().getUser().get("identify").toString())); } RelativeLayout about_us_layout = (RelativeLayout) view.findViewById(R.id.about_us_layout); about_us_layout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(getActivity(), FeedBackActivity.class); startActivity(intent); } }); RelativeLayout locationUpdate = (RelativeLayout) view.findViewById(R.id.location); locationUpdate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(getActivity(), LocationActivity.class); startActivity(intent); } }); RelativeLayout app_recommend_layout = (RelativeLayout) view.findViewById(R.id.app_recommend_layout); app_recommend_layout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(getActivity(), HelpActivity.class); startActivity(intent); } }); RelativeLayout app_password_layout = (RelativeLayout) view.findViewById(R.id.app_password_layout); app_password_layout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(getActivity(), PhoneVerifyActivity.class); startActivity(intent); } }); TextView settings_logout = (TextView) view.findViewById(R.id.settings_logout); settings_logout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(getActivity()).setTitle("??").setMessage("") .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { clearUser(); Intent intent = new Intent(getActivity(), LoginActivity.class); startActivity(intent); getActivity().finish(); } }).setNegativeButton("?", null).show(); } }); LinearLayout restaurant_info_container = (LinearLayout) view.findViewById(R.id.restaurant_info_container); restaurant_info_container.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /*startActivity(new Intent(getActivity(), UserModifyActivity.class));*/ startActivity(new Intent(getActivity(), UserUpdateActivity.class)); } }); if (hashMap.get("shopmessage") != null) { shopmessage.setText(hashMap.get("shopmessage").toString()); } LinearLayout shopmessage_layout = (LinearLayout) view.findViewById(R.id.shopmessage_layout); shopmessage_layout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final EditText editText = new EditText(getActivity()); editText.setText(hashMap.get("shopmessage").toString()); new AlertDialog.Builder(getActivity()).setTitle("?").setView(editText) .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String text = editText.getText().toString().trim(); shopmessage.setText(text); hashMap.put("shopmessage", text); updateUser(hashMap); } }).setNegativeButton("?", null).show(); } }); Thread thread = new Thread(new Runnable() { @Override public void run() { downloadBitmap(UserModifyActivity.URL + MyApplication.getUser().getUser().get("shopphoto").toString().replaceAll("\\\\", "/")); } } ); thread.start(); /* SettingsItemView settings_connect_manager= (SettingsItemView) view.findViewById(R.id.settings_connect_manager); settings_connect_manager.setOnSettingClickListener(new SettingsItemView.settingClickListener() { @Override public void rightClick() { Toast.makeText(getActivity(), "a", Toast.LENGTH_SHORT).show(); } });*/ return view; }
From source file:com.nextgis.mobile.map.LocalTMSLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, int type, final Uri uri, final LocalTMSLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);//from w w w . jav a2 s . com final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(map.getContext(), android.R.layout.simple_spinner_item); final Spinner spinner = new Spinner(map.getContext()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); adapter.add(map.getContext().getString(R.string.tmstype_qtiles)); adapter.add(map.getContext().getString(R.string.tmstype_osm)); adapter.add(map.getContext().getString(R.string.tmstype_normal)); adapter.add(map.getContext().getString(R.string.tmstype_ngw)); if (type == TMSTYPE_OSM) { spinner.setSelection(1); } else { spinner.setSelection(2); } final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); final TextView stLayerType = new TextView(map.getContext()); stLayerType.setText(map.getContext().getString(R.string.layer_type) + ":"); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); linearLayout.addView(stLayerType); linearLayout.addView(spinner); new AlertDialog.Builder(map.getContext()) .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties) // .setMessage(message) .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int tmsType = 0; switch (spinner.getSelectedItemPosition()) { case 0: case 1: tmsType = TMSTYPE_OSM; break; case 2: case 3: tmsType = TMSTYPE_NORMAL; break; } if (bCreate) { create(map, input.getText().toString(), tmsType, uri); } else { layer.setName(input.getText().toString()); layer.setTMSType(tmsType); map.onLayerChanged(layer); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show(); } }).show(); }
From source file:com.kytse.aria2remote.DownloadListFragment.java
@Override public void onClick(View v) { if (v.getId() == R.id.fab) { final EditText editText = new EditText(v.getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext()); builder.setTitle(R.string.add_url_tittle).setView(editText) .setPositiveButton(R.string.add, new DialogInterface.OnClickListener() { @Override/* w w w . j av a 2s.co m*/ public void onClick(DialogInterface dialog, int which) { String url = editText.getEditableText().toString(); new AddDownloadAsyncTask(url).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }).setNegativeButton(R.string.cancel, null).show(); } }
From source file:eu.codeplumbers.cosi.fragments.LoyaltyCardListFragment.java
private void showLoyaltyCardDetailsDialog(final Barcode barcode) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.lbl_loyalty_card_new)); // Set up the input final EditText cardName = new EditText(getActivity()); // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text cardName.setInputType(InputType.TYPE_CLASS_TEXT); builder.setView(cardName);//from ww w.j ava 2 s.com // Set up the buttons builder.setPositiveButton(getString(R.string.SAVE), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String m_Text = cardName.getText().toString(); if (m_Text.isEmpty()) { cardName.setError(getString(R.string.lbl_loyalty_cards_name_empty)); } else { Log.d(TAG, barcode.rawValue); LoyaltyCard loyaltyCard = LoyaltyCard.getByRawValue(barcode.rawValue); if (loyaltyCard == null) { loyaltyCard = new LoyaltyCard(); loyaltyCard.setCode(barcode.format); loyaltyCard.setCreationDate(DateUtils.formatDate(new Date().getTime())); loyaltyCard.setLabel(m_Text); loyaltyCard.setRawValue(barcode.rawValue); loyaltyCard.setRemoteId(""); loyaltyCard.setDeviceId(Device.registeredDevice().getLogin()); loyaltyCard.save(); } } } }); builder.setNegativeButton(getString(R.string.CANCEL), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); }
From source file:com.jdom.get.stuff.done.android.AndroidApplicationContextFactory.java
public void getTextInputForAction(String title, String hintText, String doButtonText, String dontButtonText, final RunnableWithResults<String> callback) { final EditText textView = new EditText(activity); textView.setHint(hintText);// www.ja v a 2 s .c o m AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setView(textView); builder.setTitle(title); builder.setCancelable(false).setPositiveButton(doButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { callback.callback(textView.getText().toString()); } }).setNegativeButton(dontButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); builder.show(); }