EditText vs TextView

40,972

Solution 1

If you have done any java projects before, I see Textview and EditText are just same as JLabel and JtextField . If you want to ask user to enter username you will set an TextView with ("username " text in that, like you would do the same for JLabel). And then you make a textbox appear for user to enter the username that textbox is EditText. EditText is where user give their inputs for the program.

User cannot change something in TextView but program can(After user input correct user name you can set text for another TextView by the program saying that "Details correct" if you want that you have to write it in your program code. User can't make it appear). User can input any user name, But "username" textfield or TextView will remain unchange as "username" just like in a normal login interface.

Solution 2

EditText is used for user input.

TextView is used to display text and is not editable by the user. TextView can be updated programatically at any time.

Solution 3

The names of them are pretty self explanatory. TextView is the widget used when you want the user to View the Text (such as a label, etc) and EditText used when you want the user to be able to edit the text. The text in either widget can be set programmatically or via xml using the android:text parameter.

The documentation pretty much sums it up:

EditText is a thin veneer over TextView that configures itself to be editable.

Solution 4

EditText is used when you expect an input from the user. EditText provides the behavior for user input (display keyboard, paste, position indicator, etc).

If your app is changing the content to display, you can just reset the text for the TextView. The user however cannot mess with it.

Solution 5

EditText is Input Type/Field for inputting text

TextView is TextField for showing text

Share:
40,972

Related videos on Youtube

user2927724
Author by

user2927724

Updated on July 09, 2022

Comments

  • user2927724
    user2927724 almost 2 years

    I read the API's and see that TextView is a super class to EditText, but I have a short and simple question: Generally speaking, EditText is used when the text displayed is subject to change, whether it's from the user or the app. TextView is used when the text displayed is to be constant/same forever. Is this correct?

    • Dyrborg
      Dyrborg almost 10 years
      Yes, that is correct. Often you will even leave EditText blank with just a hint, and let the user fill out the entire text.
    • Gravitoid
      Gravitoid almost 10 years
      I use a TextView when the text is subject to change. EditView if expecting user input. Of interest, everything is a view so sometimes I use a TextView with an onClick event as a button when the needs warrant (small buttons that need to look consistent across versions, simulating a combo or toggle button). I just apply the same gradient that I use on my buttons and they look the same.
  • Alexander
    Alexander about 9 years
    that's a bad comparison - an HTML label is much more - it always belongs to a form element (if you click on a label, the linked element is focused)...
  • silva96
    silva96 over 8 years
    Not correct, from TextView Documentation: Displays text to the user and optionally allows them to edit it. [link]developer.android.com/reference/android/widget/TextVie‌​w.html