android-edittext

How to set EditText box height and width programmatically in Android

[亡魂溺海] 提交于 2019-11-29 01:21:08
I want to manage the height and width of an EditText box programmatically in Android. I tried edittext.setWidth(32); and edittext.setEms(50); , but both are not working. See my below code, as I am using it to create dynamic EditText s in Android. private EditText createEditText() { final LayoutParams lparams = new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT); final EditText edittext = new EditText(this); edittext.setLayoutParams(lparams); edittext.setWidth(32); edittext.setEms(50); return edittext; } private EditText createEditText() { final LayoutParams lparams = new

EditText request focus not working

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 01:10:56
I have an EditText and a Button . On click of the button i want to open the EditText keyboard and at the same time request focus on the EditText , So that the user directly start typing in the keyboard and text appears in the EditText . But in my case when i click the button it open the keyboard, but it won't set focus on the EditText , because of which user has to click the EditText again to write on it. What is the issue. Any help or suggestion. Code On click of button m_SearchEditText.requestFocus(); InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT

EditText inside ListView will not stay focused [duplicate]

二次信任 提交于 2019-11-29 01:05:31
This question already has an answer here: Focusable EditText inside ListView 12 answers I have an EditText inside each row of a ListView . For some reason, when I tap the EditText, it briefly gains focus but then immediately loses it. I have tried these things: listView.setItemsCanFocus(true); editText.setFocusable(true); While the EditText is (briefly) focused, the Enter key says Next and the auto-correct bar is present. When it loses focus, the soft keyboard stays up, but the Enter key becomes a Return Arrow , and the auto-correct bar disappears. dmon EditText s within ListView s are

Edit text for OTP with Each letter in separate positions

非 Y 不嫁゛ 提交于 2019-11-29 00:44:16
问题 Hi I'm working on a application which asks for OTP when user want to reset his password for which I need a text like the one in attached Image... What I thought to proceed with is individual text for each of the letter, All of them arranged in linear layout of horizontal orientation with some margin... and max length as 1 so only one letter can be entered in each editText... Is that a right Approach?? Any Suggestions?? 回答1: You can try this, by making TextWatcher more Generic, so its easy to

Android Edittext Rich Text Formatting

女生的网名这么多〃 提交于 2019-11-29 00:44:09
Is there any library or open source application demo that contains Rich Text Format Edittext component with WYSIWYG interface. I've heard that android-richtexteditor contained such functionality, but it's source code is no longer available. If anyone have a link or source to the above please share it with me. Here are two awesome libraries which helped me out. Both of them are implementation of WYSIWYG. Android RTEditor: https://github.com/1gravity/Android-RTEditor RichEditor-Android: https://github.com/wasabeef/richeditor-android Their implementation code is also provided. No there is no

Why does Android change the value of EditTexts with same id?

て烟熏妆下的殇ゞ 提交于 2019-11-29 00:15:44
问题 I have a Fragment containing a LinearLayout where different items are inflated depending on some business logic. On of these items contains an EditText. When I have multiple of these items with different content and I detach/attach the fragment, all EditTexts somehow get all the same text. This only happens as long as the the EditText has an id in the layout file. Why does that happen? Is there any other way to prevent this except removing the id? I would like to use findViewById on my

android: How to get text position from touch event

断了今生、忘了曾经 提交于 2019-11-28 23:54:49
I'm wanting to implement a custom text interface, with touch+drag selecting text and the keyboard not being raised, in contrast to the default behavior of a long-click bringing up the CCP menu and the keyboard. My understanding suggests I need this approach: onTouchEvent(event){ case touch_down: get START text position case drag get END text position set selection range from START to END } I've found out all about getSelectStart() and various methods to setting a range and such, but I cannot find how to get the text position based on a touch event getX() and getY(). Is there any way to do this

How to limit EditText length to 7 integers and 2 decimal places?

梦想与她 提交于 2019-11-28 23:40:33
I have an EditText box which have to allow user to enter upto 7 numbers and two decimal places. After entering seven digits,it should not allow to add one more digit but i may allow upto 2 decimal places. I use a decimal filter for 2 decimal places and this code in XML android:maxLength="7" android:imeOptions="actionDone" android:inputType="numberDecimal" But EditText is allowing to enter 8 digits. How can this be solved? Try this under onCreate youreditText.setFilters(new InputFilter[] {new DecimalDigitsInputFilter(5,1)}); this anywhere in your program public class DecimalDigitsInputFilter

In Android, how to make Login button disable with respect to EditText?

北城以北 提交于 2019-11-28 23:24:40
问题 If EditText is empty then Login Button has to be disabled. And if EditText has some texts then Login Button has to be enabled. Well you can see this method on Instagram Login. Both fields are empty, Sign in Button is DISABLED. Here Password field is empty, so still Sign in Button is DISABLED. Here both Username and Password field is not empty, So Sign in Button is ENABLED. how to achieve these steps?? here is my code and it doesn't work.. EditText et1,et2; @Override protected void onCreate

android EditText ,keyboard textWatcher problem

巧了我就是萌 提交于 2019-11-28 22:58:01
问题 I am working on a android app and I have an EditText where user can input numbers. I want to format the number using different currency formats (say ##,##,###) and I want to do it on the fly, ie when user enter each digit(not when enter is pressed). I googled around, and came across TextWatcher which I first found promising, but it turned out to be an absolute pain. I am debugging my code on a HTC Desire phone which only has a soft keyboard. Now I want to get a callback when user press