TextView can be edited? - android

I have simple question. I am a new newbie to android. I did got through few tutorials but some responses did not work in my eclipse. I am using version 2.2.
Can we give text view the functionality of edit text of editing?

EditText extends TextView and gives it editable functionality, if you want the EditText to look like TextView, You can change the background and other style properties

User won't be able to type or edit anything in a text view. It is purely for viewing. But you could set values in a text view with user inputs from an edit text.

TextView
Displays text to the user and optionally allows them to edit it. A
TextView is a complete text editor, however the basic class is
configured to not allow editing; see EditText for a subclass that
configures the text view for editing.
You can use EditText for this.

Yes you can make Textview editable, with android:editable="true",
Please check this link for further reference..
http://developer.android.com/reference/android/widget/TextView.html#attr_android:editable
Hope this will help you

Yes, TextView can be edited. Try this:
TextView.setText();

Related

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.

Use android:EditText as label

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

layout having disabled edit text

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

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 use getSelectionStart and getSelectionEnd of TextViewwhen user touches?

I want get text like phone number inside a textView by parcing, and i want use this getSelectionStart(), but it dosen't work?? can someone give me an example please.
I made a bad first answer because I mixed getselection with the new text api of 2.3.
You will find some answer in those thread :
Android - get selection of text from EditText
How to use getSelectionStart and getSelectionEnd of EditText when user touches EditText?

Categories

Resources