Use android:EditText as label - android

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);

Related

Can i let the user delete/close an edit text if he doesn't want to type anything?

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).

AutoFill EditText Android

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.

EditText Android and inner information

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.

How to set EditText 'Hint' and 'Password' property programmatically

I'm creating a login form for my Android app, i make a single layout for both create account and login, on button click i want to change edit text hint property from 'enter user name' to 'Re enter username' and also want to change other edittext password property to true can any one help me how to change both property from code dynamicaly i saw all methods of edit text but not found any clue.
You can use .setHint() method on either your TextView or EditText.
http://developer.android.com/reference/android/widget/TextView.html#setHint(int)
EditText is an extended class of TextView. Hence, most of the methods (if not all) of TextView will work well with EditText.
You want to look at its parent class TextView, specifically setHint and setInputType.

Control Caps-Lock of android softkeypad

I have an EditText. The softkeypad should popup as "Caps on" state, when I want to edit the editText. Is there any way to do this ?
Look at the InputType property of the TextView class. Depending on what you exactly need, TYPE_TEXT_FLAG_CAP_CHARACTERS, TYPE_TEXT_FLAG_CAP_SENTENCES or TYPE_TEXT_FLAG_CAP_WORDS should do the job. You can set it either in the layout file or via code.

Categories

Resources