Java Code Examples for android.widget.EditText#setId()
The following examples show how to use
android.widget.EditText#setId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditTextPreference.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public EditTextPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mEditText = new EditText(context, attrs); // Give it an ID so it can be saved/restored mEditText.setId(com.android.internal.R.id.edit); /* * The preference framework and view framework both have an 'enabled' * attribute. Most likely, the 'enabled' specified in this XML is for * the preference framework, but it was also given to the view framework. * We reset the enabled state. */ mEditText.setEnabled(true); }
Example 2
Source File: Utility.java From MuslimMateAndroid with GNU General Public License v3.0 | 6 votes |
public static void getInput(Context context, String title, DialogInterface.OnClickListener onOkListener) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(title); final EditText input = new EditText(context); input.setInputType(InputType.TYPE_CLASS_TEXT); input.setId(R.id.text1); builder.setView(input); builder.setPositiveButton("OK", onOkListener); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); }
Example 3
Source File: DialogBuilder.java From BlackList with Apache License 2.0 | 6 votes |
/** * Adds the new edit to the list with id, text and hint **/ public DialogBuilder addEdit(int id, String text, String hint) { // inflate row using default layout LayoutInflater inflater = LayoutInflater.from(context); View itemView = inflater.inflate(R.layout.row_edit_dialog, null); // if there are some rows above if (listLayout.getChildCount() > 0) { // show top border View borderView = itemView.findViewById(R.id.item_top_border); if (borderView != null) { borderView.setVisibility(View.VISIBLE); } } // setup edit EditText editText = (EditText) itemView.findViewById(R.id.edit_text); editText.setText(text); editText.setSelection(editText.getText().length()); editText.setHint(hint); editText.setId(id); return addItem(itemView); }
Example 4
Source File: Editor.java From editor with GNU General Public License v3.0 | 6 votes |
private void saveAsDialog(String path, DialogInterface.OnClickListener listener) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.save); builder.setMessage(R.string.choose); // 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(R.id.path_text); text.setText(path); // Create the AlertDialog AlertDialog dialog = builder.create(); dialog.setView(text, 40, 0, 40, 0); dialog.show(); }
Example 5
Source File: Main.java From currency with GNU General Public License v3.0 | 6 votes |
private void updateDialog(int title, String value, int hint, DialogInterface.OnClickListener listener) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(title); // Add the buttons builder.setPositiveButton(R.string.ok, listener); builder.setNegativeButton(R.string.cancel, listener); // Create edit text Context context = builder.getContext(); EditText text = new EditText(context); text.setId(R.id.value); text.setText(value); text.setHint(hint); text.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); // Create the AlertDialog AlertDialog dialog = builder.create(); dialog.setView(text, 40, 0, 40, 0); dialog.show(); }
Example 6
Source File: TimelineActivity.java From twittererer with Apache License 2.0 | 6 votes |
private void showNewTweetDialog() { final EditText tweetText = new EditText(this); tweetText.setId(R.id.tweet_text); tweetText.setSingleLine(); tweetText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); tweetText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(140)}); tweetText.setImeOptions(EditorInfo.IME_ACTION_DONE); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.label_what_is_happening); builder.setPositiveButton(R.string.action_tweet, (dialog, which) -> presenter.tweet(tweetText.getText().toString())); AlertDialog alert = builder.create(); alert.setView(tweetText, 64, 0, 64, 0); alert.show(); tweetText.setOnEditorActionListener((v, actionId, event) -> { if (actionId == EditorInfo.IME_ACTION_DONE) { alert.getButton(DialogInterface.BUTTON_POSITIVE).callOnClick(); return true; } return false; }); }
Example 7
Source File: NumberCategory.java From FTCLibrary with MIT License | 6 votes |
/** * @inheritDoc Constructs an EditText object with input type set to number */ @Override public View getView(Context context) { //Create row LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout row = new LinearLayout(context); row.setOrientation(LinearLayout.HORIZONTAL); //Create TextView TextView t = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, null); t.setText(name); row.addView(t); //Create EditText EditText text = new EditText(context); text.setInputType(InputType.TYPE_CLASS_NUMBER); text.setId(id); row.addView(text); view = row; return view; }
Example 8
Source File: TextCategory.java From FTCLibrary with MIT License | 6 votes |
/** * @inheritDoc Constructs an EditText object with simple text input */ @Override public View getView(Context context) { //Create row LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout row = new LinearLayout(context); row.setOrientation(LinearLayout.HORIZONTAL); //Create TextView TextView t = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, null); t.setText(name); row.addView(t); //Create EditText EditText text = new EditText(context); text.setId(id); row.addView(text); view = row; return view; }
Example 9
Source File: PinViewBaseHelper.java From nono-android with GNU General Public License v3.0 | 6 votes |
/** * Generate a PinBox {@link EditText} with all attributes to add to {@link PinView} * * @param i index of new PinBox * @param inputType inputType to new PinBox * @return new PinBox */ EditText generatePinBox(int i, int inputType) { EditText editText = (EditText) LayoutInflater.from(getContext()).inflate(R.layout.partial_pin_box, this, false); int generateViewId = PinViewUtils.generateViewId(); editText.setId(generateViewId); editText.setTag(i); if (inputType != -1) { editText.setInputType(inputType); } setStylePinBox(editText); editText.addTextChangedListener(this); editText.setOnFocusChangeListener(this); pinBoxesIds[i] = generateViewId; return editText; }
Example 10
Source File: PinViewBaseHelper.java From PinView with Apache License 2.0 | 6 votes |
/** * Generate a PinBox {@link EditText} with all attributes to add to {@link PinView} * * @param i index of new PinBox * @param inputType inputType to new PinBox * @return new PinBox */ EditText generatePinBox(int i, int inputType) { EditText editText = (EditText) LayoutInflater.from(getContext()).inflate(R.layout.partial_pin_box, this, false); int generateViewId = PinViewUtils.generateViewId(); editText.setId(generateViewId); editText.setTag(i); if (inputType != -1) { editText.setInputType(inputType); } setStylePinBox(editText); editText.addTextChangedListener(this); editText.setOnFocusChangeListener(this); pinBoxesIds[i] = generateViewId; return editText; }
Example 11
Source File: RenameFileDialog.java From edslite with GNU General Public License v2.0 | 5 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setMessage(getString(R.string.enter_new_file_name)); // Set an EditText view to get user input final String filename = getArguments().getString(ARG_FILENAME); final EditText input = new EditText(getActivity()); input.setId(android.R.id.edit); input.setSingleLine(); input.setText(filename); StringPathUtil spu = new StringPathUtil(filename); String fnWoExt = spu.getFileNameWithoutExtension(); if(fnWoExt.length() > 0) input.setSelection(0, fnWoExt.length()); alert.setView(input); alert.setPositiveButton(getString(android.R.string.ok), (dialog, whichButton) -> renameFile(input.getText().toString())); alert.setNegativeButton(android.R.string.cancel, (dialog, whichButton) -> { // Canceled. }); return alert.create(); }
Example 12
Source File: ManageScriptsActivity.java From MCPELauncher with Apache License 2.0 | 5 votes |
private AlertDialog createImportFromClipboardCodeDialog() { final EditText view = new EditText(this); view.setId(20130805); return new AlertDialog.Builder(this).setTitle(R.string.script_import_from_clipboard_code). setView(view). setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogI, int button) { importFromClipboard(view.getText().toString()); } }). setNegativeButton(android.R.string.cancel, null). create(); }
Example 13
Source File: CheckPoint.java From javainstaller with GNU General Public License v3.0 | 5 votes |
public void showalert() { AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.context); alert.setTitle(text); // Set an EditText view to get user input final EditText input = new EditText(MainActivity.context); input.setId(1); if(src==false){ alert.setMessage("path to install"); input.setText(getPath()); } else{ alert.setMessage("source file"); input.setText(getSource()); } alert.setView(input); alert.setPositiveButton("save", this); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); }
Example 14
Source File: EspEditTextTest.java From espresso-macchiato with MIT License | 5 votes |
@Before public void setup() { EditText editText = new EditText(activityTestRule.getActivity()); editText.setId(editTextId); editText.setHint(HINT_TEXT); addViewToLayout(editText, BaseActivity.rootLayout); }
Example 15
Source File: AreaViewItem.java From LibreTasks with Apache License 2.0 | 5 votes |
/** * Class Constructor. * * @param id * the id used to uniquely identify this object. * @param dataTypeDbID * the database id for {@link OmniArea} * @param activity * the activity where this view item is to be built on */ public AreaViewItem(int id, long dataTypeDbID, Activity activity) { super(id, dataTypeDbID); mActivity = activity; etAddress = new EditText(activity); etAddress.setId(ADDRESS_VIEW_ID); etDistance = new EditText(activity); etDistance.setId(DISTANCE_VIEW_ID); }
Example 16
Source File: RichEditText.java From RichEditText with Apache License 2.0 | 4 votes |
private void setupView(Context context, AttributeSet attrs, int defStyleAttr,int defStyleRes){ _context = context; RelativeLayout relativeLayout = new RelativeLayout(context); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); EditText editText = new EditText(context,attrs); editText.setId(EDIT_TEXT_ID); // TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RichEditText); mRichEditEnabled = a.getBoolean(R.styleable.RichEditText_richEditAble,true); a.recycle(); mImageButton = new ImageButton(context); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics()); RelativeLayout.LayoutParams editToggleParams = new RelativeLayout.LayoutParams(px,px); mImageButton.setBackground(getResources().getDrawable(R.drawable.ic_keyboard_arrow_left_black_24dp)); editToggleParams.addRule(RelativeLayout.ALIGN_BOTTOM, EDIT_TEXT_ID); editToggleParams.addRule(RelativeLayout.ALIGN_RIGHT, EDIT_TEXT_ID); mImageButton.setLayoutParams(editToggleParams); mImageButton.setId(EDIT_TOGGLE_ID); mImageButton.setRotation(-90); mImageButton.setOnClickListener(this); View htmlOptions = inflate(context,R.layout.htmloptions,null); RelativeLayout.LayoutParams htmlOptionsLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT); htmlOptionsLayoutParams.addRule(RelativeLayout.BELOW, 1001); htmlOptionsLayoutParams.addRule(RelativeLayout.ALIGN_RIGHT, 1001); htmlOptions.setLayoutParams(htmlOptionsLayoutParams); relativeLayout.setLayoutParams(params); relativeLayout.addView(editText); relativeLayout.addView(mImageButton); //htmlOptions.setVisibility(View.GONE); if(mRichEditEnabled) { relativeLayout.addView(htmlOptions); } addView(relativeLayout); this.mEditText = editText; if(mRichEditEnabled) { findViewById(R.id.makeBold).setOnClickListener(this); findViewById(R.id.makeItalic).setOnClickListener(this); findViewById(R.id.makeUnderline).setOnClickListener(this); findViewById(R.id.makeBackground).setOnClickListener(this); findViewById(R.id.makeForeground).setOnClickListener(this); findViewById(R.id.makeHyperlink).setOnClickListener(this); findViewById(R.id.makeStrikethrough).setOnClickListener(this); findViewById(R.id.makeScaleX).setOnClickListener(this); mHtmloptions = (LinearLayout) findViewById(R.id.rich_toolbar); mHtmloptions.setVisibility(View.GONE); // mImageButton = (ImageButton) findViewById(R.id.list_toggle); // mImageButton.setOnClickListener(this); } this.mEditText.setOnClickListener(this); setOnClickListener(this); mSS = new SpannableStringBuilder(mEditText.getText()); }
Example 17
Source File: TestActivity.java From PatternedTextWatcher with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); editText = new EditText(this); editText.setId(android.R.id.primary); setContentView(editText); }
Example 18
Source File: EspDeviceTest.java From espresso-macchiato with MIT License | 4 votes |
private void givenEditTextToOpenSoftKeyboard() { EditText editText = new EditText(activityTestRule.getActivity()); editText.setId(editTextId); addViewToLayout(editText, BaseActivity.rootLayout); }
Example 19
Source File: TextViewItem.java From LibreTasks with Apache License 2.0 | 3 votes |
/** * Class Constructor. * * @param id * the id used to uniquely identify this object. * @param dataTypeDbID * the database id for {@link OmniText} * @param activity * the activity where this view item is to be built on */ public TextViewItem(int id, long dataTypeDbID, Activity activity) { super(id, dataTypeDbID); editText = new EditText(activity); editText.setId(id); }