Android: How to Add TextView and Write Text Into It?

Assuming that you were able to build the demo android application as per my previous posts and add the main.xml with the text box buttons etc., here are the steps to add a text view and write text into it. Open res/layout/main.xml and the WYSIWYG mode drag the TextView control from the left tools column in Eclipse. In the code(XML) view mode you might see something like this.

<TextView android:id="@+id/TextView01"
android:layout_below="@+id/AnalogClock01"
android:layout_width="wrap_content"
android:text="@+id/TextView01" android:layout_height="wrap_content">
 </TextView>

Notice the id of this control, it is  TextView01 in this case.

Now open your main Java class file of the applications activity and add these lines. In any of the methods as per your need.

TextView tv1 = (TextView) findViewById(R.id.TextView01);
tv1.setText("Welcome to Schogini!");