-2

Unsure of how to display text in the xml file, i have code written to output text in the java file but nothing happens when the application is run

TextView tv = (TextView) findViewById(R.id.my_text_view);
tv.setText("Welcome to the Dungeon");

*

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/my_text_view"
android:text="@string/my_text_view"/>
Bryan
  • 51
  • 1
  • 1
  • 7
  • 1
    you just create a similar question today: http://stackoverflow.com/questions/33891344/displaying-text-in-an-android-studio-project – Deividi Cavarzan Nov 24 '15 at 18:52

2 Answers2

0

Use this:

<TextView android:id="@+id/my_text_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Example"
    android:layout_gravity="center"
    android:textColor="#656565"
    android:textSize="20dp" />

And then setText

Michele Lacorte
  • 5,323
  • 7
  • 32
  • 54
0

why are you setting text twice in xml and java, just add once as: but whatever try to provide : fontsize, and gravity(center) of layout, either programmatically or in xml

Androider
  • 3,833
  • 2
  • 14
  • 24