android-edittext

Edit Text without Autocorrect

微笑、不失礼 提交于 2019-11-28 08:00:05
问题 I want an EditText without the autocorrection. I have set the textNoSuggestions inputType, as shown: <EditText android:id="@+id/txtTarga" android:layout_width="150dp" android:layout_height="wrap_content" android:ems="10" android:hint="Targa" android:inputType="textNoSuggestions|textCapCharacters" > The capitalize flag works, but it is still autocorrecting. How can I disable it? 回答1: inputType textVisiblePassword will do the trick (most of the times, because as Commonsware pointed out, it

Keyboard suggestions cause part of Android EditText.setError() message to not display

不想你离开。 提交于 2019-11-28 07:40:51
When I'm using edittext.setError("enter a comment") in android, it works fine until the keyboard suggestions come up and the error gets pushed above the edittext , after which it does not display the whole error message. Why is it doing this? setError Sets the right-hand compound drawable of the TextView to the "error" icon and sets an error message that will be displayed in a popup when the TextView has focus. The icon and error message will be reset to null when any key events cause changes to the TextView's text. If the error is null, the error message and icon will be cleared. So when the

Android: Limiting EditText to numbers

情到浓时终转凉″ 提交于 2019-11-28 07:30:14
问题 When creating an EditText in the java portion of the application, how do you limit it to numbers like you would in the xml? For example: new EditText(this); set like <EditText android:id="@+id/h1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="numberDecimal"/> 回答1: Something like this perhaps ? EditText text = new EditText(this); text.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL); 回答2: Use of android:numeric is deprecated, use android:inputType

Soft keyboard hides half of EditText

安稳与你 提交于 2019-11-28 07:27:51
I have a listview and the last list item contains EditText: <RelativeLayout android:id="@+id/contentLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="30dp" android:orientation="vertical" > <ImageView android:id="@+id/test" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignRight="@+id/messageEditText" android:layout

Listview with edittext - auto scroll on “next”

帅比萌擦擦* 提交于 2019-11-28 07:16:38
问题 I have a ListView with one EditText on each row (in addition to a couple of non-editable TextView's). When I'm editing the text in the EditText, the soft keyboard has "Next" button - and pressing it moves the focus to the next field - this is great. On the last row, the button changes to "Done". I'm using EditText.setImeOptions to set the button to "Done" or "Next" based on whether this is the last row or not. The problem is that the listview can have more rows that can fit on the screen.

How to disable cursor positioning and text selection in an EditText? (Android)

风格不统一 提交于 2019-11-28 07:14:55
I'm searching for a way to prevent the user from moving the cursor position anywhere. The cursor should always stay at the end of the current EditText value. In addition to that the user should not be able to select anything in the EditText. Do you have any idea how to realize that in Android using an EditText? To clarify: the user should be able to insert text, but only at the end. I had the same problem. This ended up working for me: public class CustomEditText extends EditText { @Override public void onSelectionChanged(int start, int end) { CharSequence text = getText(); if (text != null) {

How to set editable true/false EditText in Android programmatically?

大憨熊 提交于 2019-11-28 07:13:10
We can set editable property of EditText in XML layout but not programatically, but there is no setEditable() method! If EditText is not Enabled [ by setEnabled(false) ] it still Editable ! sat I did it in a easier way , setEditable and setFocusable false. but you should check this. How to replicate android:editable="false" in code? JAL This may help: if (cbProhibitEditPW.isChecked()) { // disable editing password editTextPassword.setFocusable(false); editTextPassword.setFocusableInTouchMode(false); // user touches widget on phone with touch screen editTextPassword.setClickable(false); // user

how to insert image to a editText

别等时光非礼了梦想. 提交于 2019-11-28 07:06:24
I want to insert a image to a editText my code is: CharSequence charSeq= editText.getText()+" "; SpannableString ss2 = new SpannableString(charSeq); Drawable d2 = holder.image.getDrawable(); d2.setBounds(0, 0, d2.getIntrinsicWidth(), d2.getIntrinsicHeight()); ImageSpan span2 = new ImageSpan(d2, ImageSpan.ALIGN_BASELINE); ss2.setSpan(span2,charSeq.length()-1, charSeq.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); editText.setText(ss2,BufferType.SPANNABLE); My code can run but i have some not bad experience i want to modify: 1: You know when use ss2.setSpan() method, the image can replace the

Android : How to set acceptable numbers and characters in EditText?

六月ゝ 毕业季﹏ 提交于 2019-11-28 06:57:27
I have to set acceptable characters "0123456789" and "semicolon" in the EditText. Below is the code I'm using. android:digits="0123456789;" android:inputType="number|text The problem with that implementation is in HTC phones, semicolon can't be entered but in Samsung and Sony Ericsson, semicolon can be entered. Another problem is when I entered semicolon in Samsung and Sony Ericsson, semicolon can't be deleted. Is there any missing property in the above code? Thanks in advance. Shankar Agarwal Android provides an easy way to edit text fields by modifying the layout xml and adding an android

Android EditText.setError() yields invisible error text

眉间皱痕 提交于 2019-11-28 06:53:10
I have a very simple EditText, as follows: <EditText android:id="@+id/myedit" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:maxLength="32"/> In some validation code, I use Android's EditText.setError() to show any validation errors. This works fine in OS 2.x but not on an OS 3.x device (Xoom) -- on the Xoom you can see the outline of the error popup but you cannot see the error text. I'm guessing that the text is there, but it is invisible. How do I make it visible? I don't see an android:textColor that would relate to error text.