List of usage examples for android.widget EditText EditText
public EditText(Context context)
From source file:br.pro.menotti.opus.pt.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); db = new SQLiteHelper(getApplicationContext()); String listStr[] = getResources().getStringArray(R.array.listString); ListView lv = (ListView) findViewById(android.R.id.list); lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listStr)); lv.setOnItemClickListener(new OnItemClickListener() { @Override//from w w w . ja va 2 s . c o m public void onItemClick(AdapterView<?> parent, View view, int position, long id) { SQLiteHelper db; switch (position) { case 0: showBooks(); break; case 1: AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()); builder.setTitle(R.string.display_search); final EditText input = new EditText(view.getContext()); builder.setView(input); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String search_key = input.getEditableText().toString().trim(); if (!search_key.equals("")) { showPoints(search_key); } } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); break; case 2: db = new SQLiteHelper(getBaseContext()); db.openDataBase(); showFavorites(); db.close(); break; case 3: db = new SQLiteHelper(getBaseContext()); db.openDataBase(); BookPoint bp = db.getBookPoint(); DialogFragment newFragment = new DialogPoint(bp); newFragment.show(getSupportFragmentManager(), bp.toString()); db.close(); break; default: Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show(); } } }); try { db.createDataBase(); } catch (IOException ioe) { throw new Error("Unable to create database"); } try { db.openDataBase(); db.close(); } catch (SQLException sqle) { throw sqle; } }
From source file:com.github.capone.controller.favorites.FavoritesFragment.java
@Override public void onClick(View v) { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); final EditText name = new EditText(getActivity()); name.setHint(R.string.server_name);/* w ww.j av a 2 s . c om*/ final EditText address = new EditText(getActivity()); address.setHint(R.string.server_address); final EditText publicKey = new EditText(getActivity()); publicKey.setHint(R.string.public_key); LinearLayout layout = new LinearLayout(getActivity()); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(name, params); layout.addView(address, params); layout.addView(publicKey, params); new AlertDialog.Builder(getActivity()).setTitle(R.string.title_add_favorite) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { addServer(name.getText().toString(), address.getText().toString(), publicKey.getText().toString()); } }).setView(layout).show(); }
From source file:com.sahana.geosmser.view.ReverseGeocoderView.java
public void initialUIComponent() { mTextView = new TextView(mContext); mEditText = new EditText(mContext); mButton = new Button(mContext); mTextView.setId(3);//ww w .j a v a 2s. c om mEditText.setId(1); mButton.setId(2); mTextView.setText(""); mEditText.setHint("EX: ???"); mButton.setText(""); RelativeLayout.LayoutParams mTextLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams mEditLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams mButtonLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); mTextLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); mEditLayoutParams.addRule(BELOW, mTextView.getId()); mButtonLayoutParams.addRule(RIGHT_OF, mEditText.getId()); mButtonLayoutParams.addRule(ALIGN_BASELINE, mEditText.getId()); mButton.setOnClickListener(getGeocoder); this.addView(mTextView, mTextLayoutParams); this.addView(mEditText, mEditLayoutParams); this.addView(mButton, mButtonLayoutParams); }
From source file:de.nico.asura.activities.AuthWebView1.java
private void checkLogin() { // Layout for Dialog LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); final EditText edit_name = new EditText(this); edit_name.setHint(getString(R.string.menu_AuthWeb_1_fiFi)); layout.addView(edit_name);//from www .j a v a 2 s.c om final EditText edit_pass = new EditText(this); edit_pass.setHint(getString(R.string.menu_AuthWeb_1_seFi)); edit_pass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); layout.addView(edit_pass); Builder builder = new Builder(this); builder.setTitle(getString(R.string.menu_AuthWeb_1_name)).setCancelable(false).setView(layout) .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { firstField = edit_name.getText().toString(); secondField = edit_pass.getText().toString(); // Nothing? if (firstField.length() == 0 || secondField.length() == 0) { Utils.makeShortToast(AuthWebView1.this, getString(R.string.wrong)); checkLogin(); return; } Editor editor = prefs.edit(); editor.putString("firstFirst", firstField); editor.putString("firstSecond", secondField); editor.commit(); openWebView(); } }).setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { AuthWebView1.this.finish(); } }).show(); }
From source file:cc.softwarefactory.lokki.android.utilities.DialogUtils.java
public static void addPlace(final Context context, final LatLng latLng, final int radius) { final EditText input = new EditText(context); // Set an EditText view to get user input input.setSingleLine(true);/*from w w w . java 2 s . c om*/ final AlertDialog addPlaceDialog = new AlertDialog.Builder(context) .setTitle(context.getResources().getString(R.string.write_place_name)).setView(input) .setPositiveButton(R.string.ok, null).setNegativeButton(R.string.cancel, null).create(); addPlaceDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { ((FragmentActivity) context).findViewById(R.id.add_place_overlay).setVisibility(View.INVISIBLE); // todo maybe re enabled this... it will however also fire on empty input } }); addPlaceDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { addPlaceDialog.getButton(AlertDialog.BUTTON_POSITIVE) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Editable value = input.getText(); if (value == null || value.toString().isEmpty()) { input.setError(context.getResources().getString(R.string.required)); return; } try { ServerApi.addPlace(context, value.toString(), latLng, radius); } catch (JSONException e) { e.printStackTrace(); } addPlaceDialog.dismiss(); } }); } }); addPlaceDialog.show(); }
From source file:com.bordengrammar.bordengrammarapp.ParentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_parents, container, false); mail = (LinearLayout) root.findViewById(R.id.linmail); call = (LinearLayout) root.findViewById(R.id.lincall); call.setOnClickListener(new View.OnClickListener() { @Override//from www.ja va 2s .c om public void onClick(View arg0) { Intent cally = new Intent(Intent.ACTION_CALL); cally.setData(Uri.parse("tel:01795424192")); startActivity(cally); } }); mail.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Send a email to Borden Grammar"); alert.setMessage("Message: "); final EditText input = new EditText(getActivity()); alert.setView(input); alert.setPositiveButton("Send", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); // Do something with value! Intent email = new Intent(Intent.ACTION_SEND); email.setType("plain/text"); email.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "school@bordengrammar.kent.sch.uk" }); email.putExtra(Intent.EXTRA_SUBJECT, "Email (Sent From BGS APP) "); email.putExtra(Intent.EXTRA_TEXT, value); startActivity(Intent.createChooser(email, "Choose an Email client :")); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); } }); URL url = null; try { url = new URL( "http://website.bordengrammar.kent.sch.uk/index.php?option=com_rubberdoc&view=category&id=63%3Aletters&Itemid=241&format=feed&type=rss"); } catch (MalformedURLException e) { e.printStackTrace(); } Feed feed = null; try { feed = FeedParser.parse(url); } catch (FeedIOException e) { e.printStackTrace(); } catch (FeedXMLParseException e) { e.printStackTrace(); } catch (UnsupportedFeedException e) { e.printStackTrace(); } Boolean nully = false; for (int i = 0; i < 3; i++) { try { FeedItem item = feed.getItem(i); } catch (NullPointerException e) { e.printStackTrace(); nully = true; Toast.makeText(getActivity().getApplicationContext(), "Some features of this app require a internet connection", Toast.LENGTH_LONG).show(); } } if (!nully) { final FeedItem post1 = feed.getItem(1); final FeedItem post2 = feed.getItem(2); final FeedItem post3 = feed.getItem(3); TextView title1 = (TextView) root.findViewById(R.id.title1); TextView title2 = (TextView) root.findViewById(R.id.title2); TextView title3 = (TextView) root.findViewById(R.id.title3); title1.setText(post1.getTitle()); title2.setText(post2.getTitle()); title3.setText(post3.getTitle()); TextView link1 = (TextView) root.findViewById(R.id.link1); TextView link2 = (TextView) root.findViewById(R.id.link2); TextView link3 = (TextView) root.findViewById(R.id.link3); link1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url1 = post1.getLink().toString(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url1), "text/html"); startActivity(intent); } }); link2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url1 = post2.getLink().toString(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url1), "text/html"); startActivity(intent); } }); link3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url1 = post3.getLink().toString(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url1), "text/html"); startActivity(intent); } }); } else { TextView title1 = (TextView) root.findViewById(R.id.title1); TextView title2 = (TextView) root.findViewById(R.id.title2); TextView title3 = (TextView) root.findViewById(R.id.title3); title1.setText("No connection"); title2.setText("No connection"); title3.setText("No connection"); } TextView reader = (TextView) root.findViewById(R.id.reader); reader.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String appPackageName = "com.adobe.reader"; // getPackageName() from Context or Activity object try { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName))); } } }); return root; }
From source file:jfabrix101.lib.dialog.MessagePromptDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); b.setTitle(this.getArguments().getString("title")); b.setPositiveButton(getActivity().getString(android.R.string.ok), this); b.setNegativeButton(getActivity().getString(android.R.string.cancel), this); b.setMessage(this.getArguments().getString("message")); editText = new EditText(getActivity()); // Set the optional param HINT String hits = getArguments().getString(PARAM_HINT); if (hits != null) editText.setHint(hits);/* w w w. ja v a 2s . co m*/ // Set the optional param INPUT_TYPE int inputType = getArguments().getInt(PARAM_INPUT_TYPE, -1); if (inputType > 0) editText.setInputType(inputType); b.setView(editText); return b.create(); }
From source file:com.androidhacks7.apprtc_android.RegistrationActivity.java
private void showUserDialog(int type, final Object... args) { AlertDialog.Builder builder = new AlertDialog.Builder(this); if (type == AppConstants.DIALOG_USERNAME) { builder.setMessage("Enter User Name: "); userName = new EditText(this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); userName.setLayoutParams(lp);// w w w .j a v a2 s. c om builder.setView(userName); builder.setPositiveButton("Enter", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { register(); } }); builder.setNegativeButton("Quit", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { finish(); } }); } else if (type == 1) { try { final JSONObject jsonObject = new JSONObject(args[0].toString()); builder.setMessage("Incoming call from " + jsonObject.get(JSONConstants.CALLER)); builder.setPositiveButton("Attend", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(RegistrationActivity.this, VideoCallActivity.class); intent.putExtra(JSONConstants.CALL_PARAMS, args[0].toString()); startActivity(intent); finish(); } }); builder.setNegativeButton("Decline", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(RegistrationActivity.this, VideoCallActivity.class); intent.putExtra(JSONConstants.CALL_PARAMS, args[0].toString()); intent.putExtra(JSONConstants.REJECT_CALL, args[0].toString()); startActivity(intent); } }); } catch (JSONException e) { e.printStackTrace(); } } builder.create().show(); }
From source file:com.facebook.react.views.textinput.ReactTextInputShadowNode.java
@Override public void setThemedContext(ThemedReactContext themedContext) { super.setThemedContext(themedContext); // {@code EditText} has by default a border at the bottom of its view // called "underline". To have a native look and feel of the TextEdit // we have to preserve it at least by default. // The border (underline) has its padding set by the background image // provided by the system (which vary a lot among versions and vendors // of Android), and it cannot be changed. // So, we have to enforce it as a default padding. // TODO #7120264: Cache this stuff better. EditText editText = new EditText(getThemedContext()); setDefaultPadding(Spacing.START, ViewCompat.getPaddingStart(editText)); setDefaultPadding(Spacing.TOP, editText.getPaddingTop()); setDefaultPadding(Spacing.END, ViewCompat.getPaddingEnd(editText)); setDefaultPadding(Spacing.BOTTOM, editText.getPaddingBottom()); mDummyEditText = editText;//from w w w . ja v a 2 s .c o m // We must measure the EditText without paddings, so we have to reset them. mDummyEditText.setPadding(0, 0, 0, 0); // This is needed to fix an android bug since 4.4.3 which will throw an NPE in measure, // setting the layoutParams fixes it: https://code.google.com/p/android/issues/detail?id=75877 mDummyEditText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); }
From source file:com.normalexception.app.rx8club.dialog.MoveThreadDialog.java
/** * Constructor for method that is used to move a thread from one * forum to another /*from ww w. j a v a 2 s. c o m*/ * @param ctx The source context/activity * @param securitytoken The security token for the session * @param src_thread The source thread * @param tTitle The new thread title * @param options The options from the move dialog */ public MoveThreadDialog(final Fragment ctx, final String securitytoken, final String src_thread, String tTitle, final Map<String, Integer> options) { builder = new AlertDialog.Builder(ctx.getActivity()); // Set up the input final TextView lbl_title = new TextView(ctx.getActivity()); final EditText title = new EditText(ctx.getActivity()); final TextView lbl_dest = new TextView(ctx.getActivity()); final Spinner destination = new Spinner(ctx.getActivity()); // Lets make sure the user didn't accidentally click this DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: newTitle = title.getText().toString(); String selectText = destination.getSelectedItem().toString(); selection = options.get(selectText); AsyncTask<Void, String, Void> updaterTask = new AsyncTask<Void, String, Void>() { @Override protected Void doInBackground(Void... params) { try { HtmlFormUtils.adminMoveThread(securitytoken, src_thread, newTitle, Integer.toString(selection)); } catch (Exception e) { Log.e(TAG, "Error Submitting Form For Move", e); } return null; } @Override protected void onPostExecute(Void result) { ctx.getFragmentManager().popBackStack(); CategoryFragment cFrag = (CategoryFragment) ((ThreadFragment) ctx).getParentCategory(); cFrag.refreshView(); } }; updaterTask.execute(); break; case DialogInterface.BUTTON_NEGATIVE: break; } } }; // Specify the type of input expected lbl_title.setText("Thread Title"); lbl_title.setTextColor(Color.WHITE); lbl_dest.setText("Desination"); lbl_dest.setTextColor(Color.WHITE); title.setInputType(InputType.TYPE_CLASS_TEXT); title.setText(tTitle); List<String> values = new ArrayList<String>(); values.addAll(options.keySet()); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(ctx.getActivity(), android.R.layout.simple_spinner_item, values); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); destination.setAdapter(dataAdapter); LinearLayout ll = new LinearLayout(ctx.getActivity()); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(lbl_title); ll.addView(title); ll.addView(lbl_dest); ll.addView(destination); builder.setView(ll); builder.setTitle(R.string.dialogMoveThread).setPositiveButton(R.string.Move, dialogClickListener) .setNegativeButton(R.string.cancel, dialogClickListener); }