• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps java code for plain text

pathanos

Newbie
I wanna show text, not just one line, but several. How do I do this? Also some of these will be codes (that I do not want to be coded, just show the code). Codes like HTML and CSS.
 
Definitely declare the text view and change the text programmatically. Using setText() on your text view can too clunky depending on your text, but append() works very nicely by adding the text to what's already in the text view. You'll need "\n" for a new line of text of course and probably setText("") at the beginning of your loop to clear the text fresh.

Editing individual words isn't perfect, but by using append() you can do it fairly easily

MyTextView.setText("");;
MyTextView.append("John really enjoys ");
if(John likes hamburgers)
MyTextView.append("hamburgers.");​
else if(John likes hot dogs)
MyTextView.append("hotdogs.");​
MyTextView.append("\nYum!");

This will give you

John really enjoys hamburgers.
Yum!

or

John really enjoys hotdogs.
Yum!

So you haven't exactly picked out the word and changed it, but you can code it in such a way that you make the if statements around the individual words.

Putting in HTML and CSS code shouldn't be an issue.
 
Back
Top Bottom