I need to achieve the similar behavior from the image below. I need to add extra static information inside an EditText in android that does not change according to the user's input (except for the character count).
How do I achieve this? As per I see from the focus, the data is inside the EditText and not out, so i believe this is some sort of style or a custom component.
Many Thanks
T
What you could do is make a view group with the text how you want it with an EditText at the top for the user input, then set the background of your view group to android:background="#android:drawable/editbox_background"
use setText() method of EditText with the appropriate BufferType
for the top text, and setHint() for the bottom one.
Related
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.
I want to set some text in EditText type fields. I want to do this while loading the activity. And then I don't want user to make any changes to it. Can I set EditText type boxes to non-editable mode? Does there exists any other element which could solve my purpose?
A TextView sounds like what you want; you can call setText() on them.
For EditText itself you could call this version of setText(), and set the buffer type to NORMAL instead of EDITABLE.
there are two options.
setEditable and setEnable. set false in Oncreate.
but in setEditable user can edit text by long click -> paste option.
If you are not taking any input from user in the EditText and it is just used to show some text that is set programmatically at onCreate, then you can use TextView instead. It is more suited for your requirement.
Here is a comparison between EditText and TextView that might be helpful.
Is there any particular reason for you to use a non-editable EditText? In case you absolutely have to use EditText then setting it as non-editable in your code after you set the value will suffice. You can do it in a few different ways, one of them would be setting input type as null in code.
yourEditText.setInputType(InputType.TYPE_NULL);
You can do android:enabled="false" in layout of that activity.
or
editText.setEnabled(false);
I need to create custom EditText so it will look like this:
I need it to be single EditText. Is it possible to do it, or do I need to create EditText for every character?
Yes it is possible! create multiple edit text's depending on the number of characters you want to accept as input and make sure to limit the size of each edit text to 1
android:maxLength="1"
You can set the width of each edit text and place them horizontally one after the other
You can create custom EditText by extending it. And you have to implement addTextChangeListener and their you can draw whatever you want. But No need to re Invent the wheel
And you can also use some build in customView like
PinView
Another
Also have a look at this
I am building one app having one list view showing list of users this, when i click on list item it will show me complete profile of clicked user this. I take EditText fields on this layout (i use the same layout to show my own profile which is editable) whose text is filled dynamically(e.g., data of clicked user is filled in this form).Since, it only show me profile of concern user & i not need any editing on user data so i disable editing on these edit text fields by calling this method on each one.
setEnabled(false)
this layout is scrollable and when i scroll this view it enable editing on these edit text field this
How i disable editing on these edit text field...???
Any suggestions please, would appreciated any pointer, sample code to do this
Actually, an EditText is needed when you want to enable user to type some information. To draw the information generated by your application you should use a TextView, which by default does not give the opportunity to change text contexts. Usually, a disabled EditText misleads users, making them feel like they've done something wrong, so try to use proper views for solving common problems. Hope this helps.
You can take TextView instead of EditText as it is a label, and if you still want it to look like edit field. you can use default editfield background by setting background of textView to
#android:drawable/edit_text in xml file.
In XML of editText write android:editable="false".
I'm trying to make iPhone-style EditText element on android.
The one that will have an additional clear button appear on the right after text input.
Adding a new button is not a problem, but I'm a bit stuck with another thing.
A button occupies some space on the right part of EditText, and now characters display beneath the button. How to change maximum shown length of input for EditText?
I want EditText width to be N pixels, and editable area to be N-M pixels.
EditText.setWidth changes width for whole edit box.
EditText.setEllipsize should be the proper solution, but docs are empty, and as I see it truncates text based on some String value.
Applying a LengthFilter cut's the input length to number of characters.
Thanks in advance.
I suspect that android:drawableRight will save you a lot of pain.
Seems I've found a solution.
EditText.setPadding(l,t,r,b) seems to work fine, applying only for editable area
Try this : http://mytechead.wordpress.com/2012/02/07/create-ios-like-cleartextbutton-in-android/
This is a very old question, but thought I'd add my two cents for kicks. I'd probably use a 9 patch for this and set the content area to stop the text before it hits the button area.
This would require creating a custom view so that you can add a button in the desired position using relative layout so that it can be clicked to clear the edittext.
Alternatively you can use the compound drawables, but you would need to implement something like this
Handling click events on a drawable within an EditText so that you can handle the click events. Keep in mind that I doubt the button states (eg the down state) will work using this method.