For all those new Android developers out there, here is how you can set text and display it on your Android application’s front end.

TextView textViewObject = new TextView(this);

textViewObject.setText(“Hello, Android”);

setContentView( textViewObject);

The output on the screen would look like :


Here you create a TextView class’s object textViewObject with the class constructor, which accepts an Android Context instance as its parameter.

Next, you define the text content with setText().

Finally, you pass the TextView to setContentView() in order to display it as the content for the Activity UI.

Leave a Reply

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