Trouble with TextView Class
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 -
I am trying to display "dataView1" within my MainActivity.java file like this -
Everything complies but my dataView1 does not show up on app screen.
TextView planetNameValue (TextView)findViewById(R.id.dataView1);
Thanks in advance.
July 12th, 2013, 06:21 PM
Hmm, based on what you have shown, it should show fine. A few things to check:
- Are the references of "toRightOf" textView5 and "above" textView2 correct? It could be pushing it off the screen if textView2 or textView5 has positioning that causes it to do so. May be worth removing or modifying those lines from your XML temporarily to see if it shows period. I use IntelliJ to do my Android development, and it has a great "preview" option for XML layout files.
- Is your string resource "@string/planet_name_label" correctly populated with a string? If so, try removing the line from the Java that sets the text to "earth.planetName". It may be setting the TextView's string to "" and you may not be realizing it.
If neither of the above works, can you post your entire XML layout file? Also, can you put a log statement right before the setText() call, which prints out the value of "earth.planetName"?