I have an EditText with a TextWatcher attached to it and the onChangeText method works flawlessly.
I'd like to add a mini icon/button at the very right end of the EditText, which clears the text and then disappears.
May I have some direction on how to implement this? I don't want source code, but an idea on what mechanism to use. Thank you in advance.
I would say you have it in your Layout permanently as you want it to look but you normally have the Visibility set to GONE then just set it to VISIBLE when you want it shown.
Related
i have a lot of EditTexts. I want the user to delete some edittexts if he doesn't want to type anything and i want that edittext to go away from the screen. Can i do that?
Yes you can do that by changing the visibility. First set visibility of the edittext as setVisibility(View.INVISIBLE) then setVisibility(View.GONE).
I'm trying to create a search bar like.
I have to use a particular autofill, infact I can't use a dropdowns menu.
For example if I write Noce the edittext will have to suggest Nocera in the same editText, like this.
but if the user write something else the pointer have to the end of the typed text (in this case Noce) and the hint have to disappear.
Is there some library that allows me this?
Thanks for the help.
There's this library that will fulfill some of your requirement called Auto Fill EditText
Finally I have solved this using two EditText in the same position. The first one is a normal editable EditText, the second one is not editable from the user but is used to show the hints programmatically.
My app has an EditText that, when I click in it to enter text in the Emulator, brings up a soft keyboard. I don't want this confounded thing to begin with, but then, like the visiting loud-mouthed uncle in the plaid pants, doesn't want to go away, and it is blocking the button beneath it. How do I either (a) prorgrammatically prevent the soft keyboard from appearing or at least (b) evict it, albeit manually, when it pops up?
Provided that the user is not supposed to input text, but is able to click the EditText and then add text in some other way, you could change the EditText to a TextView and then apply the following three tags to it in the layout file:
style="#android:style/Widget.EditText"
android:editable="false"
android:focusableInTouchMode="false"
This will make it look like an EditText, but behave like a TextView.
Since you want the user to be able to write stuff in the EditText there are in my opinion two solutions:
Leave it be. To remove the keyboard, all you need is to hit the back button once and every Android user knows this. It's standard behaviour.
Wrap everything but the Button you say dissapears in a ScrollView. The ScrollView will then wrap its content to allow the Button to be shown in between the keyboard and the ScrollView.
Just set android:editable="false" for your EditText
The answer is to set the focus on an other View like a Button, TextView or similar:
// REQUEST FOCUS
viewName.setFocusableInTouchMode(true);
viewName.requestFocus();
I think what you really need is take a look at android:windowSoftInputMode attribute in Manifest.xml Look into this link.
You can specify the screen to pan/ resize to show the buttons that the input method might be blocking. Not allowing the keyboard to show will make the user unable to enter text at all!
i have an AutoCompleteTextView widget on the view. if it has input focus and I'm trying to change the text in there with:
txtField1.setText("test");
I'm getting suggestions list appears on the screen. How do I hide it? is it possible to update the text not showing suggestions?
I'll leave this here, in case someone needs it in the future, like I did.
yourAutoCompleteTextView.dismissDropDown();
will make the list with suggestions disappear from the screen.
I suggest some methods
1)If you want to make "test" like hint of autocomplete textView then do like this,
txtField1.setHint("test");
2)If you need to fill up the text view with "test" and also need to prevent the suggestion increase the threshold level for auto complete textview ,
txtField1.setThreshold(5);
if you use threshold it will show suggestion after 5 character (according to the code posted in above line). If you need try to set different word and also try to avoid suggestion , change the threshold dynamically based on length of string.
Hey guy's
First of all thanks for reading this.
I'm having trouble to find a way to change my EditText when I loose focus to it.
I would like it to be greyed out when this happens, but I don't want it to be disabled because the user can touch it and edit the text later.
Anyone?
Greetings!
You can set different colors to the text based on an OnFocusChangeListener
Another option is to set a style in xml. See this question for details: Android: change style when focused
To change the opacity, use setAlpha. In this answer I show it how to do it in an animation: Two questions about custom app ui's and AlphaAnimation