How to use Textbox Control using Xml file

In Android, Textbox displays text to the user and optionally allows them to edit it programmatically. TextView is a complete text editor, however basic class is configured to not allow editing but we can edit it.

We can create a TextView instance by declaring it inside a layout(XML file) or by instantiating it programmatically (Java Class).

TextView code in XML:

TextView code in JAVA:

Example Of Text View :

Step 1: Create a new project and name it textViewExample.

  • Select File -> New -> New Project. Fill the forms and click “Finish” button.

Step 2: Open res -> layout -> xml (or) activity_main.xml and add following code. Here we will create a textview in Relative Layout.

Step 3: Open app -> java -> package and open MainActivity.java and add the following code. Here we will change the text of TextView.

Output :

Now run the app in Emulator and click on the button. You will see text will change “After Clicking”.

Textbox

About Jaimin Patel

I am a Web Developer. I have been blogging and researching since 1 years and like to share my knowledge and research with the world. Peace..!!

View all posts by Jaimin Patel →

Leave a Reply

Your email address will not be published. Required fields are marked *