android-edittext

Create two-way binding with Android Data Binding

痴心易碎 提交于 2019-11-28 04:51:22
I have implemented the new Android data-binding, and after implementing realised that it does not support two-way binding. I have tried to solve this manually but I am struggling to find a good solution to use when binding to an EditText. In my layout I have this view: <EditText android:id="@+id/firstname" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textCapWords|textNoSuggestions" android:text="@{statement.firstName}"/> Another view is also showing the results: <TextView style="@style/Text.Large" android:layout_width="wrap_content" android:layout

Change Size of EditText bottom border

我怕爱的太早我们不能终老 提交于 2019-11-28 04:45:52
I have some EditText in my code and I want to make the bottom border of it a bit thinner. Couldn't find anything about it in the Internet, maybe anyone here can help me with it. What I have: What I want: Try like this for focus effects: edt_bg_selector.xml : <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/edt_bg_selected" android:state_focused="true"/> <item android:drawable="@drawable/edt_bg_normal" android:state_focused="false"/> </selector> edt_bg_normal.xml : <?xml version="1.0" encoding="utf-8"?

RxTextView.textChanges with setText on Edittext

可紊 提交于 2019-11-28 04:37:31
问题 RxTextView.textChanges(editText) .map(CharSequence::toString) .debounce(200, TimeUnit.MILLISECONDS) .observeOn(AndroidSchedulers.mainThread()) .subscribe(input -> { output = //...do something with input editText.setText(ouput) })); When I setText(output) it goes in loop. To set the text I first need to remove listener and then set listener again. How can I do this using RxJava ? 回答1: When I setText(output) it goes in loop. To set the text I first need to remove listener and then set listener

EditText added is not a TextInputEditText. Please switch to using that class instead

梦想与她 提交于 2019-11-28 04:36:24
I'm using an EditText inside a TextInputLayout , but after upgrading the support library to 23.2.0, I get this warning in the logcat, What's the difference between a regular EditText and a TextInputEditText ? I can't seem to find any documentation for it. TWiStErRob I was wondering this too, Daniel Wilson gathered the documentation, but to the untrained eye it doesn't mean much. Here's what it's all about: "extract mode" is referring to the type of view that's shown when the space is too small, for example landscape on a phone. I'm using Galaxy S4 with Google Keyboard as IME. Landscape UI

Make EditText ReadOnly

余生颓废 提交于 2019-11-28 04:36:14
I want to make a read-only EditText view. The XML to do this code seems to be android:editable="false" , but I want to do this in code. How can I do this? Nikhil Please use this code.. Edittext.setEnabled(false); If you setEnabled(false) then your editText would look disabled (gray, etc). You may not want to change the visual aspect of your editor. A less intrusive way would be to use setFocusable(false) . I believe that this answers your question closer to your initial intent. Salim In XML use: android:editable="false" As an example: <EditText android:id="@+id/EditText1" android:layout_width=

How do listen EditText?

主宰稳场 提交于 2019-11-28 04:30:24
问题 I have a EditText . I wamt tp do something, when the user presses the Enter key while changing EditText . How can I do that? The most simplest method: final EditText edittext = (EditText) findViewById(R.id.edittext); edittext.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // Perform action on key

how to disable paste option in android EditText

给你一囗甜甜゛ 提交于 2019-11-28 04:29:08
问题 I have an requirement where EditText doesn't allow paste but it should allow copy. I tried setCustomSelectionActionModeCallback but it disable copy option. EditText etxt = (EditText) findViewById(R.id.editText1); etxt.setCustomSelectionActionModeCallback(new Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public

Prevent enter key on EditText but still show the text as multi-line

你。 提交于 2019-11-28 04:27:28
How do I make an EditText on Android such that the user may not enter a multi-line text, but the display is still multi-line (i.e. there is word-wrap instead of the text going over to the right)? It's similar to the built-in SMS application where we can't input newline but the text is displayed in multiple lines. I would subclass the widget and override the key event handling in order to block the Enter key: class MyTextView extends EditText { ... @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode==KeyEvent.KEYCODE_ENTER) { // Just ignore the [Enter] key return true;

Android: Insert text into EditText at current position

*爱你&永不变心* 提交于 2019-11-28 03:53:36
I want to insert a constant string into an EditText by the press of a button. The string should be inserted at the current position in the EditText. If I use EditText.append the text gets inserted at the end of the EditText. How can I do that? I couldn't find a suitable method. Cpt.Ohlund Try using EditText.getSelectionStart() to get the current position of the cursor. Then you can use String.subString to get the text before and after the cursor and insert your text in the middle. Manuel Cpt.Ohlund gave me the right hint. I solved it, now, partly with using EditText.getSelectionStart() , but I

edittext.settext() changes the keyboard type to default [ from ?123 to ABC]

妖精的绣舞 提交于 2019-11-28 03:08:48
问题 I have following code for my edittext formatting, since it can take any input I am not setting any input type: if (cardNumberEditText != null) { cardNumberEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { int currSel = cardNumberEditText.getSelectionStart(); cardNumberEditText.removeTextChangedListener(textWatcher); . . cardNumberEditText.setText(formattedNumber); . . cardNumberEditText.setSelection