android-edittext

Android 6 EditText.setError not working correctly

只谈情不闲聊 提交于 2019-12-04 17:40:26
问题 I have upgraded to android 6 and seeing some strange things when trying to set validation for some editTexts. I am using android-saripaar for validation: @Email(messageResId = R.string.error_email) private EditText email; @Password(min = 6, scheme = Password.Scheme.ALPHA_NUMERIC_MIXED_CASE_SYMBOLS) private EditText password; @ConfirmPassword private EditText repassword; @NotEmpty(messageResId = R.string.error_name) private EditText firstname; @NotEmpty(messageResId = R.string.error_name)

Add EditText to Toolbar

我的未来我决定 提交于 2019-12-04 17:13:43
问题 My Toolbar and EditText look like this: I tried adding it as an ActionView but I got this result: It basically just added my words 'Tap Below' as a title without the TextView Here's what I did: menu.xml <menu> ... ... <item android:id="@+id/edit_text_menu" android:orderInCategory="300" android:title="Tap Below" android:actionLayout="@layout/edit_text_layout" app:showAsAction="ifRoom|collapseActionView" /> </menu> edit_text_layout.xml <?xml version="1.0" encoding="utf-8"?> <EditText xmlns

How to set font style of selected text using custom typeface through spannable method

一个人想着一个人 提交于 2019-12-04 17:10:14
I want to set style to selected text from EditText using custom typeface . I am getting below error at compile time. The constructor StyleSpan(Typeface) is undefined . Below code I am applying. int start=editbox.getSelectionStart(); int end=editbox.getSelectionEnd(); Spannable span=(Spannable)editbox.getText(); StyleSpan f = new StyleSpan( Typeface.createFromAsset(getAssets(), "fonts/genbkbasr.ttf")); span.setSpan(f, start,end, 0); Thanks. I wrote a class to work around this limitation. It appeared to work in limited testing, but I haven't yet written the application that I needed it for. Note

How to reposition cursor while editing EditText field which is formatted like US currency- Android

核能气质少年 提交于 2019-12-04 17:09:52
I am formatting edit text field as per US currency format, where while typing number in a field, let's say "12345678" it appears like "12,345,678". For this I have used TextWatcher and on afterTextChanged(...) method I am formatting the entered text like: @Override public void afterTextChanged(Editable editable) { String str = editable.toString(); String number = str.replaceAll("[,]", ""); if (number.equals(previousNumber) || number.isEmpty()) { return; } previousNumber = number; DecimalFormat formatter = new DecimalFormat("#,###.##", new DecimalFormatSymbols(Locale.US)); String

How to determine if an input in EditText is an integer?

北战南征 提交于 2019-12-04 17:09:47
问题 Hi I'm a newbie in Android Programming. I'm trying to build an activity which includes an edittext field and a button . When user type in an integer, the button will lead them to the next activity. However I do not if there's a way to check the type of user's input. Anyone can help me? Thank you very much! 回答1: Update: You can control the EditText to only accept numbers <TextView . . . android:inputType="number" /> or check it programmatically In Kotlin val number = editText123.text.toString(

Exception when focusing a EditText in a PopupWindow running on Device

浪尽此生 提交于 2019-12-04 17:06:33
问题 I'm developing a PopUp window for Android, and it's working, I added a EditText and a Button on that, when running on ADV this work properly, while running on device, when I focus on the EditText this throws a weird Exception. android.view.WindowManager$BadTokenException: Unable to add window - - token android.view.ViewRoot&48163b18 is not valid; is your active running? I don't know if it matters, but I'm running on a Galaxy Tab with Swype input. Now I read the specs of the Window

EditText´s android:nextFocusDown attibute stops working when onClick is set

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 17:04:23
Does anybody knows why the android:nextFocusDown attibute stops working when we set the onClick on it? On the example below, we have some EditText with this attribute defined: <TableRow android:weightSum="1" android:gravity="center"> <EditText android:id="@+id/txtChave1" android:maxLength="4" android:gravity="center" android:textSize="16dp" android:layout_height="wrap_content" android:layout_weight=".23" android:layout_width="0dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:singleLine="true" android:selectAllOnFocus="true" android:inputType="textCapCharacters"

How to change EditText pointer color (not cursor)

醉酒当歌 提交于 2019-12-04 16:11:10
问题 I'm trying to make the pointer color of EditText to become blue. I'm able to make the underline and the cursor to become blue, but the droplet looking pointer is still grey. I google a bit, but all the links that appear only talk about how to change the cursor, not the pointer. So if anybody knows how to do this, I need your help. I only need to support Android 5.0 and above. So if your solution only works on API > 21, that's totally fine. Thanks! 回答1: in your styles.xml put like this: <item

Android Edittext- Clearing Spans

邮差的信 提交于 2019-12-04 15:57:53
问题 I am trying to get an EditText to clear its spans by calling EditText.getText().clearSpans() . However, if I call this method, the EditText starts to behave strangely, with line feeds appearing as boxes and any spans I then set being in completely the wrong place. So my question is: How do I clear spans from and EditText? (Without calling setText()- the text may be thousands of lines long and its too slow to redraw it all frequently) Thanks very much! 回答1: Had the same problem. Solved it by

how to change highlight color on editText field

試著忘記壹切 提交于 2019-12-04 15:48:15
问题 Below is a screen shot of a custom edit text field i have in my android app. While you are type a given word, the text for the word you are currently typing highlights in grey and shows the text as black, until you hit the space bar at which time the text turns white as expected. Is there a way to change the color of the highlight and the text that is highlighted? my edit text xml looks like this <EditText android:id="@+id/searchField" android:layout_width="160dp" android:layout_height="44dp"