android-edittext

android EditText inputType for StreetNumber field

跟風遠走 提交于 2019-12-08 22:08:32
问题 I'm trying to choose correct inputType in my adress dialog streetNumber field. I want to show numeric keyboard first, but then let user also to input alphabetic characters for some very special cases. Closer to this is inputType datetime, but this doesn't allow to enter alphabetic characters. So how to set my streetNumber field correctly? 回答1: Use android:inputType="textPostalAddress" 回答2: The EditText inherits from TextView and shares its input type attributes with it. They can be found here

Android: How to track if soft-keyboard is openned?

痴心易碎 提交于 2019-12-08 21:28:57
问题 In my application, the device soft-keyboard is covering the EditTextViews, so user cannot see what he is typing. So i want to hide other Views(like a button in my case), to make the EditTextViews visible. But instead on doing something like EditText.onFocus(){ //hide button } for every EditText, i want to do something like if(soft-keyboard.isOpenned()) //hide button } how to track if soft-keyboard is openned or closed? Edit: Actually my layout is this: <?xml version="1.0" encoding="utf-8"?>

Android EditText: how to apply spans when composing?

对着背影说爱祢 提交于 2019-12-08 19:38:29
How can I apply spans on EditText text when the user is composing? For example the user has activated "bold" when composing, so every character input since then should be bold . I thought about adding text change listener to the EditText and update the text as the user composes, but I wanna know if there's a better way of doing this. The question was already answered in the comments, but to make it more permanent I will add a fuller answer. In order to set a span (like Bold) wherever the user is composing, you just set a span on the text at the cursor (or selection) position. StyleSpan

Is there a way to track this exception: focus search returned a view that wasn't able to take focus

我们两清 提交于 2019-12-08 19:28:50
问题 I get some crash logs with Crashlytics with the following stack: Fatal Exception: java.lang.IllegalStateException: focus search returned a view that wasn't able to take focus! at android.widget.TextView.onKeyUp(TextView.java:6413) at android.view.KeyEvent.dispatch(KeyEvent.java:2712) at android.view.View.dispatchKeyEvent(View.java:9960) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630) at android.widget.ScrollView

EditText Values in Android Fragment do not refresh

霸气de小男生 提交于 2019-12-08 19:23:17
问题 I'm using the Viewpager to switch between 3 fragments , everything is working fine, except the refreshing of the second tab (or fragment ). In this tab, I have a picture, some static Textviews , some dynamic TextViews and some EditText fields. Everytime the second tab is selected, there will be called setText() on all dynamic fields. TextView components and the spinner are refreshing and updating their contents, but EditText elements do not. I don’t understand why these fields are not

OnFocusChange not always working

做~自己de王妃 提交于 2019-12-08 19:15:57
问题 In one of my activities I have three EditText s and an OK button. The OnFocusChangeListener is set to all three EditText s. The listener should trigger every time the focus is lost. Switching between EditText s works perfectly. But if the user presses the OK button there's no focus change (losing the focus) triggered for the EditText the user focused before pressing the button. What's wrong with my code? private class MyOnFocusChangeListener implements OnFocusChangeListener { private EditText

I can not adjust the edittext linespacing

末鹿安然 提交于 2019-12-08 18:48:34
I want to adjust the line spacing of edittext. I use a long line, and when I cross the line, linespacing is applied. However, linespacing does not apply when I input Enter key. This Library fixed the EditText linespacing issue https://github.com/hanks-zyh/LineHeightEditText use this code for line space between two line android:lineSpacingExtra="10dp" whole code is <EditText android:id="@+id/edittext" android:layout_margin="@dimen/activity_horizontal_margin" android:layout_width="match_parent" android:layout_height="wrap_content" android:lineSpacingExtra="10dp" //set the line space between 2

How to search and Highlight Text within an EditText

送分小仙女□ 提交于 2019-12-08 18:46:33
I've searched high and low for something that seems to be a simple task. Forgive me, I am coming to Android from other programming languages and am new to this platform and Java. What I want to do is create a dialog pop-up where a user enters text to search for and the code would take that text and search for it within all the text in an EditText control and if it's found, highlight it. I've done this before, for example in VB and it went something similar to this pseudo code: grab the text from the (EditText) assign it to a string search the length of that string (character by character) for

Android Edittext cursor invisible

偶尔善良 提交于 2019-12-08 18:03:39
问题 I have an edittext in my application that will show the cursor correctly in Froyo or Gingerbread, however in later sdks the cursor is invisible. I have found online the solution is to set the android:textCursorDrawable="@null" so that the edittext will use the font color for the cursor. However, since my minsdkversion is 8, I do not have access to that property. Is their either a way to selectively add a property based on the sdk you are on? Or possibly a way to work around this so that I can

Change EditText setError drawable gravity

此生再无相见时 提交于 2019-12-08 17:43:25
问题 For EditText that going be filled with RTL text, is there a way to change the gravity of the error drawable (and popup of course) ? here is an example of regular error drawable so since the text entered is RTL i would like the pop up to show up at the LEFT side of the EditText i tried to apply custom drawable , but Drawable doesnt seem to have any setGravity method. thanks in advance. 回答1: It's not possible by normal means, however you can extend the Android TextView class and change the