Add text view to the Layout
activity_numbers.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/res/android" android:layout_width="match_parent" android:lyout_height="match_parent" android:paddingBottom="16dp" android:paddingLeft="16dp" android:paddingRight="16dp" android:paddingTop="16dp" android:orientation="vertical" android:id="@+id/rootView" tools:context="com.example.android.miwok.NumbersActivity"> </LinearLayout>
android:textView class
https://developer.android.com/reference/android/widget/TextView.html
/.../ package com.example.android.miwok; public class NumbersActivity extends AppCompactActivity { @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_numbers); // Create on array of words ArrayList<String> words = new ArrayList<String>(); words.add("one"); words.add("two"); words.add("three"); words.add("four"); words.add("five"); words.add("six"); words.add("seven"); words.add("eight"); words.add("nine"); words.add("ten"); LinearLayout rootView = (LinearLayout)findViewById(R.id.rootView); TextView wordView = new TextView(this); wordView.setText(words.get(0)); rootView.addView(wordView); TextView wordView2 = new TextView(this); wordView2.setText(words.get(1)); rootView.addView(wordView2); TextView wordView3 = new TextView(this); wordView3.setText(words.get(2)); rootView.addView(wordView3); } }