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?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
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.
EditText is Input Type/Field for inputting text
TextView is TextField for showing text
TextView is just like Label tag of HTML on the other hand Edittext is input type.
Simple telling TextView is can't changable by the user. User only enter value.
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.
If you have done any java projects before, I see
Textview
andEditText
are just same asJLabel
andJtextField
. 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 isEditText
. 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.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.