Setting text into a ContentView
How do I go about setting texts/images 开发者_Python百科into a Image and Content View I have in an xml?
I have something like:
tv.setText("Random Number: " + Math.random()); if (currentHour > 8 && currentHour < 22) { tv.setText("Random number:" + random + "%");
but I want the displayed text (tv) to be displayed in a new xml file, Result.
setContentView(R.layout.result);
Is there a way to gather information like the random number, etc..and have the results displayed in a new layout - Result?
Thanks!
This question makes no sense. Layout XML is static, it simply tells LayoutInflater
what views to create, what properties to set, and how to link them all together.
If you want to change the activity's layout then call setContentView(R.layout.result)
and then call findViewById()
to find the EditText
you want and then call setText()
on that.
精彩评论