android-edittext

How can I prevent the cursor from resizing in an EditText (MultiAutoCompleteTextView) after I add an imagespan using a SpannableStringBuilder?

拟墨画扇 提交于 2019-12-01 00:26:29
Here is what it looks like in the beginning when I haven't added any imagespan chips - As you can tell there the cursor is placed at the right size and the gravity is respected. Then when I add an imagespan, the cursor all of a sudden becomes bigger like this - I don't understand why this happens and I also don't know how to fix it, i.e. keep the cursor the same size. Finally when I start typing again, the cursor is all wierd while maintaining the size of the of the font and the span also moves a little to the bottom. I really want to the keep the cursor the same size and keep it centered I'm

android EditText maxLength not working

允我心安 提交于 2019-12-01 00:05:29
问题 This is my xml <EditText android:id="@+id/et_comment" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textNoSuggestions|textVisiblePassword" android:hint="Provide comments here..." android:gravity="top" android:maxLength="5" android:textSize="12sp" android:visibility="visible" /> Neither is it working using this code TextView editEntryView = new TextView(...); InputFilter[] filterArray = new InputFilter[1]; filterArray[0] = new InputFilter

Edittext android automatic focus

烈酒焚心 提交于 2019-11-30 23:38:56
问题 I have an issue when the activity starts, android automatically places focus on the first edittext. How do I prevent android from doing that? 回答1: Have a look here Or you could just hide the keyboard, focus remains on the EditText upon starting the activity: android:windowSoftInputMode="stateHidden" 回答2: use setFocusable (boolean focusable) to prevent. http://developer.android.com/reference/android/view/View.html#setFocusable(boolean) 回答3: Three ways to solve this.. Set these attributes to

Android: Make multiline edittext scrollable, disable in vertical scroll view

为君一笑 提交于 2019-11-30 23:14:39
I am developing an application in which i am struct at a point. As according to my application requirement i created horizontal scrollview in xml and then vertical scrollview in .java as : // Vertical Scroll view in Linear layout ScrollView scrollView = new ScrollView(this); scrollView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); Then i created a table view programatically and added it in scrollview. I created multiline edit text and disable it because i want to set text in it run time and added this in table view as a row.. EditText editText = new

detect keyboard search button

*爱你&永不变心* 提交于 2019-11-30 22:31:56
问题 I change android soft keyboard to show search icon rather than Enter icon. My question is: how i can detect that user click on that search button? 回答1: In the edittext you might have used your input method options to search. <EditText android:imeOptions="actionSearch" android:inputType="text"/> Now use the Editor listener on the EditText to handle the search event as shown below: editText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction

How to change the color of the line in ICS styled EditText

别等时光非礼了梦想. 提交于 2019-11-30 22:29:22
I and using ABS together with theme holo in my application and i get EditText styled as if in ICS. But the line color of the EditText is blue by default and for my design, i need white colored line for the EditText. I tried changing the background, but it is not working. Is there any way so that I can change the color from blue line to white programmatically? Aswathy P Krishnan I found the answer in this link where they are using LayerList I used a layer-list for creating an ICS styled edittext as it was needed only in one place. It works great and no issues found with varying screen

Android Get EditText Input Type At Runtime

陌路散爱 提交于 2019-11-30 22:17:40
I have a custom implementation of an edit text class. Based on these XML attribute..... android:inputType="textPersonName" android:inputType="textPersonName" android:inputType="textEmailAddress" android:inputType="textPassword" I want to be able to know this at run time (In Java Code) I have found this method which gives me the input type getInputType() And these are the values returned based on the XML I posted above. 97,97,33,129 However, these do not correspond to the constant values listed here http://developer.android.com/reference/android/text/InputType.html How can I know the input type

Select edittexts text in a listview. How can be done? I can't find out

白昼怎懂夜的黑 提交于 2019-11-30 22:14:25
I have a ListView with an EditText on each row working. I need to select this text on click the edittext to write numbers without erasing or moving the cursor. Using selectAllonfocus at first works. However, after scrolling the listview, the EditText got crazy and selection doesn't work correctly. If I execute selectAll in the listener onFocus, then when a touch is made the contextmenu (select word, select all,etc) is shown instead of the selection. If someone can help. Thanks. I can't tell what it is that you are trying to do. Perhaps it'd help if you can post some of your relevant source

Removing style from selected text in edittext

断了今生、忘了曾经 提交于 2019-11-30 22:07:19
My app should allow users to style inputted or selected text in an Edittext. Some of these styles are Underline, Strike through, Bold and Italic. They are easily added but I don't know how they could be removed and how I could determine if that style has already been added to the selected text. Code for adding style: Spannable str = myEditText.getText(); if (!SpannableUtils.isEmpty(str)) { str.setSpan(new StrikethroughSpan(), startSelection, endSelection, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } I tried using removeSpan but it didn't work. Also tried using str.setSpan(new StyleSpan(android

Android: Edittext- get current line

馋奶兔 提交于 2019-11-30 21:55:10
In an edittext is there a method for getting the current line of the cursor? If not I will write my own method, but just wanted to check. If I do write my own method would the best method be to go through every character in the edittext until selectionstart and count the number of \n's using a For loop, or is there a better way? Thanks! Henry Thompson Just to let people know: There is a better way to do this then Doug Paul has suggested by using the getLineForOffset(selection) : public int getCurrentCursorLine(EditText editText) { int selectionStart = Selection.getSelectionStart(editText