Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch between a TextView and EditText

Is this possible to interchange a TextView and an EditText. Like display the text when needed, but allow editing when needed. Is there a method (as in NON-XML) way of editing a TextView or non-editing a EditText?

like image 829
Mohit Deshpande Avatar asked Sep 03 '10 17:09

Mohit Deshpande


People also ask

What is difference between TextView and EditText?

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.

Is EditText a subclass of TextView?

Android EditText is a subclass of TextView. EditText is used for entering and modifying text. While using EditText width, we must specify its input type in inputType property of EditText which configures the keyboard according to input.

What is the difference between TextView and plain text in android Studio?

Textview : should be used for uneditable text which user wants to read but not to manipulate. e.g. News, Articles, Blogs. Plain text/ Edittext : should be used for taking user input in alphanumeric form. e.g. UserId, Comments.

What is EMS in EditText?

The em is simply the font size. In an element with a 2in font, 1em thus means 2in. Expressing sizes, such as margins and paddings, in em means they are related to the font size, and if the user has a big font (e.g., on a big screen) or a small font (e.g., on a handheld device), the sizes will be in proportion.


1 Answers

Is this possible to interchange a TextView and an EditText.

Put both in your layout in the same spot. Make one invisible. Toggle visibility as needed.

Or, put both as children of a ViewSwitcher or ViewFlipper, and use that to switch between them.

Is there a method (as in NON-XML) way of editing a TextView or non-editing a EditText?

No, AFAIK.

like image 112
CommonsWare Avatar answered Oct 26 '22 04:10

CommonsWare