android-edittext

Android select and highlight text in edittext

时间秒杀一切 提交于 2019-12-08 03:39:27
I would like to do an app which has an EditText or TextView that can be selected upon click and highlight the selected text. How can I do that? I tried overriding onClick method on my EditText but seems not working. Here's what I've tried so far: etx.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { int startSelection = etx.getSelectionStart(); int endSelection = etx.getSelectionEnd(); //String selectedText = etx.getText().toString().substring(startSelection, endSelection); Spannable spannable=new SpannableString(etx.getText().toString());

Android EditText with fixed number of max lines and no scrolling

我与影子孤独终老i 提交于 2019-12-08 03:02:08
问题 I would like to create a text input that: 1) Always displays 3 lines 2) Does not allow the user to enter any more text than the available space in the 3 lines 3) Is not scrollable, if users enters text greater than 3 lines. Technically, I allow for the user to enter up to 500 chars for saving to DB, but I am not expecting near this amount of text for the input. So, my usage of maxLength is only precautionary. Here is my current EditText: <EditText android:id="@+id/edit_description" android

Android: EditText maxLength being ignored

試著忘記壹切 提交于 2019-12-08 02:51:25
I have a problem where this EditText ignores my maxLength completely. <EditText android:id="@+id/dialog_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:inputType="numberPassword" android:maxLength="4" android:singleLine="true" android:textColorHint="@color/primary_lighter" android:textColor="@color/accent_harder" android:hint="****" /> I can input how many characters I want. This is a dialog and I cannot get the EditText by findViewById because its available programtaically when I press OK. public void showNewQuestionDialog()

How to set multiple colors to a floating Edittext's hint?

我是研究僧i 提交于 2019-12-08 02:27:44
问题 Is there a way to set multiple colors to the edittext's hint when wrapped by android.support.design.widget.TextInputLayout without compromising the behaviour of floating edittexts? AFAIK The only way to set multiple colors to the edittext hint is by using SpannableStringBuilder. But when the editext is wrapped by TextInputLayout and the hint set programmatically using a SpannableStringBuilder, it behaves like a normal editext which does not float (the labels aren't floating) Whereas if the

How to use more then one imeOptions in android

泄露秘密 提交于 2019-12-08 02:09:40
问题 Is it possible to use more then 1 imeOptions in Android xml ? for the same text field . e.g. <EditText android:id="@+id/mywriting" android:imeOptions="actionDone" android:imeOptions="autoText"/> Right now it is giving me an error, saying 1 imeOptions has already been used and I can't use any more 回答1: Use | to combine, like that: android:imeOptions="actionDone|actionNext" In your case, the problem is with autoText , which is not a valid value for imeOptions . 回答2: <EditText android:id="@+id

Android Development: How To Get All EditText Children of a ViewGroup?

徘徊边缘 提交于 2019-12-08 01:31:58
问题 Basically, I have a LinearLayout that holds a random amount of horizontal LinearLayouts, and in each of the horizontal LinearLayouts there's a TextView and an EditText. I want to be able to get the value of each EditText children of the master LinearLayout. Sorry if it's confusing, I'm no good at explaining things! Could I just set the same ID for each of the EditTexts then use findViewById, or would that only return the first instance of an EditText? Thanks, Alex. 回答1: You would need to call

Edittext “lag” android

不羁岁月 提交于 2019-12-08 00:21:18
问题 The first time i focus an edittext view i notice a lag of one or two seconds before i can write anything in the textbox. I notice this behavior even on an app without any code more than what's nessecary to initialize the application. What am i doing wrong? 回答1: I've INSTANTLY fixed this issue for me; I saw in the DDMS that a lot of redraw's and recalculations were occurring while entering text, and a lot of info about RelativeLayouts were being called. So, I checked my layout; i had some

Android Create aligned fields Layout

廉价感情. 提交于 2019-12-07 23:08:21
问题 Here's my issue I have a login and want to line up the EditText fields. See the mockup picture attached . I have tried a few ways and cannot figure out how to make the fields lineup. I really hate layouts in Android I spend more time just messing with things to line up right. Wish they would just scrap it and use something more intuitive, as its more like using tables in HTML. So in advance thanks for your help and cheers! 回答1: You could probably play around with RelativeLayout and get just

Hint Not Displaying When numeric=“integer” in EditText

浪尽此生 提交于 2019-12-07 17:45:28
问题 The title is the question. Anybody know any solution? Please help me. Shaiful 回答1: The XML attribute android:numeric is not a boolean value and "true" is not a valid parameter, it must be one ore more of "integer", "signed", "decimal". Per the sample you've posted, your issue is due to the choice of adding gravity to center the text. There is a known bug in the SDK that, as of 2.3, it looks like is still not fixed. This bug hides the hint text when android:singleLine and any custom value of

EditText cursor visible even if the EditText is not editable

元气小坏坏 提交于 2019-12-07 17:43:53
问题 I need to introduce data in an EditText but i want to use an virtual keyboard, not the android keyboard. If I use setKeyListener(null) the cursor is invisible even after using setCursorVisible(true) . Is it possible to make an EditText where even if it isn't editable the cursor is visible ? EDIT 2 : I found an partial method to do that, but it's not working when i'm double taping the EditText. I made an setOnClickListner() and an setOnLongClickListner() method for the EditText . In this