android-edittext

Enable Scrolling within EditText that is in a ScrollView

最后都变了- 提交于 2019-12-23 10:39:50
问题 Our app (WordPress for Android) uses a scrollview for the new post view, where a user enters in their new blog post. There's quite a few fields on this view, including a large EditText for the post content field. It appears that when an EditText is in a ScrollView, the ScrollView takes over the scrolling action, so the user can't scroll within the EditText area if they are writing a large post. What can be done so that scrolling will work both within the EditText and the ScrollView? Here is

Android check spaces in EditText

不羁岁月 提交于 2019-12-23 10:26:38
问题 I have a problem regarding Edit Text in Android. I have a field named Username : I want that whenever someone writes a username with a space e.g "Gaurav Arora". Then it should raise a toast or error on the login button press. I did in this way - I simply stopped the effect of space bar with the help of a text watcher as- public static TextWatcher getNameTextWatcher(final TextView agrTextView) { TextWatcher mTextWatcherName = new TextWatcher() { public void onTextChanged(CharSequence arg0, int

Change TextInputLayout focused & unfocused hint color programmatically

a 夏天 提交于 2019-12-23 10:19:59
问题 I wanted to change the color of hint in TEXT INPUT LAYOUT same when it is in focused or unfocused state.i have two TEXT INPUT LAYOUT fields.Both fields are same color.But it in focused state color appears but in an unfocused state the default grey color appears.i want to keep the color color of hint same in both focused and unfocused state. <com.example.viveka.snipeid.CustomTextInputLayout android:id="@+id/input_layout_name" android:layout_width="match_parent" android:layout_height="wrap

Android - Delete entire ImageSpan when part of it is deleted?

徘徊边缘 提交于 2019-12-23 10:17:50
问题 I'm adding an image to my edittext by inserting an ImageSpan. I don't have a thorough understanding of spans but it seems that my ImageSpan needs to wrap a portion of text. So I add some text to the EditText, and wrap it with my ImageSpan and it appears fine. However, when I backspace the ImageSpan, it only deletes one character of the text and the image remains until the entire text is delete. How do I get it to just delete with one backspace? SpannableStringBuilder builder = new

Android onkey - dispatchKeyEvent not firing

跟風遠走 提交于 2019-12-23 09:49:37
问题 well, I've tried all the solutions I could find on stackoverflow and in other places, but the end result hasn't changed one bit: the only key that triggers the onKey event or the dispatchKeyEvent is the enter key on the virtual keyboard, and only if pressed twice. I cannot intercept any other key (there's a breakpoint at the top of the event and eclipse never stops on it, except for in case of the aforementioned enter). Beheaviour is the same on both emulator and real device. Any ideas? Thank

java.lang.IndexOutOfBoundsException: setSpan (N … N) ends beyond length 10500

痴心易碎 提交于 2019-12-23 09:35:05
问题 I get this exception when I call EditText.setSelection() java.lang.IndexOutOfBoundsException: setSpan (N ... N) ends beyond length 10500 N can be any number. For example if I call setSelection(10476,10568) N will be 10568. But 10500 is constant. java.lang.IndexOutOfBoundsException: setSpan (10568 ... 10568) ends beyond length 10500 at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1090) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:665)

Change part of text color within an “EditText” widget

若如初见. 提交于 2019-12-23 09:34:51
问题 I'm +- new to android and was wondering if it's possible to change only part of the text color in a EditText widget... Actually i'm making a notepad app where you would be able, for example, to write "bblablabal" and then click on the "yellow" button and keep writing in yellow color (the text written before doesn't have to change, as it does with the .setTextColor() method). I've tried some of the java methods and also tried some workarounds with no succes... any ideas of how to makes this

Can I set something like “tooltip” for a view in android?

不问归期 提交于 2019-12-23 08:54:03
问题 Can I set some message to appear like a "tooltip" for a TextView or Button? 回答1: There's no concept of "hovering" in a touch screen, but you could set a LongClickListener for your View, and have a Toast appear after a long press. Something like this: Toast viewToast = Toast.makeText(this, "My View Tooltip", Toast.LENGTH_SHORT); View myView = (View)findViewById(R.id.my_view); myView.setOnLongClickListener(new OnLongClickListener() { @Override public void onLongClick(View v) { viewToast.show();

Can I set something like “tooltip” for a view in android?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 08:52:02
问题 Can I set some message to appear like a "tooltip" for a TextView or Button? 回答1: There's no concept of "hovering" in a touch screen, but you could set a LongClickListener for your View, and have a Toast appear after a long press. Something like this: Toast viewToast = Toast.makeText(this, "My View Tooltip", Toast.LENGTH_SHORT); View myView = (View)findViewById(R.id.my_view); myView.setOnLongClickListener(new OnLongClickListener() { @Override public void onLongClick(View v) { viewToast.show();

Currency input with 2 decimal format

时光总嘲笑我的痴心妄想 提交于 2019-12-23 08:00:14
问题 I need to format input currency with 2 decimal format example when user enter 2 it looks $2.00 then when when user enter 2 it convert to $22.00 ... etc I approach to something similar , when user enter 2 it convert to $0.02 next 2 will be like this $0.22 any one can help me thank you public class MoneyTextWatcher implements TextWatcher { private final WeakReference<EditText> editTextWeakReference; public MoneyTextWatcher(EditText mEditText) { editTextWeakReference = new WeakReference<EditText