1. Are you ready for the Galaxy S20? Here is everything we know so far!

Trouble with TextView Class

Discussion in 'Android Development' started by simpson_121919, Jul 8, 2013.

  1. simpson_121919

    Thread Starter

    I can not seem to dynamical put variables on my app. text screen. Within my activity_main.xml file I have created an id like this -
    [HIGH]<TextView
    android:id="@+id/dataView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView2"
    android:layout_marginLeft="36dp"
    android:layout_toRightOf="@+id/textView5"
    android:text="@string/planet_name_label" />[/HIGH]

    I am trying to display "dataView1" within my MainActivity.java file like this -
    [HIGH]TextView planetNameValue = (TextView)findViewById(R.id.dataView1);
    planetNameValue.setText(earth.planetName);[/HIGH]

    Everything complies but my dataView1 does not show up on app screen.
    Thanks in advance.
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Armuro

    Armuro Newbie

    Many possible reasons there. First try to replace "earth.planetName" with a string such as

    planetNameValue.setText("test")

    to see if your textview appears. If yes, your planetName content may be null. Print it out to check its content.
     
Loading...

Share This Page

Loading...