Monday, June 22, 2026

How to set text to a TextView.

How to set text to a Text View.

Today you are going to set a text to a text view.

Step 1:
  • Open Android Studio.
  • Create new project.


Step 2:
  •  Double click on "app" from the left panel.
  •  Then Double click on "res" 
  • Then Double click on "layout"
  • and open "activity_main.xml" file.

Step 3:
  • Find the text view in the file .
  • Give some id to it.


Step 4:
  • Go back on side panel.
  • Double click on "java" 
  • Double click on package.
  • open "MainActivity"

Step 5 : 
        Let do some code.
  • Below this line " setContentView(R.layout.activity_main)"
  • Start typing.
           TextView textView = (TextView) findViewById(R.id.text);

           textView.setText("My New Text");



Step 6 :
  • Click on Save button from Toolbar.
  • Click on Run.
  • Select Android Virtual Device(AVD).
  • Click Ok.
Step 7 :

















        
         

No comments:

Post a Comment