Very simple, yet I can't figure it out.

Put your problem here if it does not fit any of the other categories.

Very simple, yet I can't figure it out.

Postby JoelB » Wed Dec 03, 2008 2:05 am

I'm guessing you guys know this one.

Code: Select all
       // rules of the game below
        TextView tv = new TextView(this);
        tv.setText("I am Line 1" +
              "I am Line 2"
          setContentView(tv);
        // display rules


As you can see, what I am trying to do is create a new line.
But, it seems impossible?

I can't think of any other possible way.

Help? please?
JoelB
Freshman
Freshman
 
Posts: 2
Joined: Wed Dec 03, 2008 2:00 am

Top

Postby faiz.india » Wed Dec 03, 2008 10:09 am

See if the code below works.

// rules of the game below
TextView tv = new TextView(this);
tv.setText("I am Line 1 n I am Line 2");
setContentView(tv);
// display rules
faiz.india
Developer
Developer
 
Posts: 32
Joined: Mon Jul 28, 2008 12:21 pm
Location: Pune - India

Postby MrSnowflake » Wed Dec 03, 2008 11:00 am

Maybe (not sure though):
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. textView.setText("line1<br />line2.");
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


What you are doing is almost no (real) programming language a way to get a newline in a string. It's only a way to divide a string over multiple lines mostly for readability.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby JoelB » Thu Dec 04, 2008 1:42 am

hey guys thanks for your suggestions, but it seems neither work.

I would place an image inside, however, I have no clue how to do this.

I prefer plain text anyhow, any other ideas?

-JoelB
JoelB
Freshman
Freshman
 
Posts: 2
Joined: Wed Dec 03, 2008 2:00 am

Postby kenjkelly » Thu Dec 04, 2008 7:25 am

I actually made line returns where I wanted by creating a resource string and putting a linefeed in the middle of the string:

<string name="test"> This is a test
of making a linefeed</string>

I also did this in a resource string: <string name="welcome_button1">Configure <b>App Name </b></string> to make the app name bold when displayed by a TextView.

Ken
kenjkelly
kenjkelly
Freshman
Freshman
 
Posts: 7
Joined: Mon Oct 06, 2008 3:30 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 8 guests