TextView and \n

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

TextView and \n

Postby javai » Fri Jan 08, 2010 12:01 am

Hi guys,

I'm reading some XML data into my app..

The problem is if a n appears, the text, from then onwards is truncated for some reason

Here's my view

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>


<TextView android:id="@+id/text1"
    xmlns:android="http://schemas.android.com/apk/res/android"
   
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize = "18sp"
    android:singleLine = "true"
   
    android:height = "35sp"
    android:paddingTop = "7sp"
     android:paddingBottom = "7sp"
    />
 
   


Can someone please point me in the right direction?

Thanks
javai
Freshman
Freshman
 
Posts: 8
Joined: Sun Sep 13, 2009 11:52 pm

Top

Postby jwei512 » Fri Jan 08, 2010 12:13 am

Not sure what the XML of your TextView has to do with your problem, but couldn't you do a simple replace function?

For instance, if you're using some kind of StringBuilder to build the string from an InputStream, then if the character is a 'n' just ignore it. Or, if you aren't reading it in one character at a time and instead your XML is just a String, then just call the replace('n', '') on the String.

Is this what you were going for?
- jwei

http://thinkandroid.wordpress.com
Examples, Code, and Tutorials
jwei512
Senior Developer
Senior Developer
 
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA

Postby javai » Fri Jan 08, 2010 12:28 am

Thanks for the quick reply.

The "n" i dont want to ignore, I want that to display a new line in my textView..

I printed the text in my log, and it seems to be truncated before it even gets displayed in the TextView.. So prob isnt in textView but in my code reading the XML.

thanks for your help :)
javai
Freshman
Freshman
 
Posts: 8
Joined: Sun Sep 13, 2009 11:52 pm

Postby jwei512 » Fri Jan 08, 2010 2:16 am

Oh wait...

Is it because you have:

android:singleLine = "true"

in your TextView XML layout?

That would make sense because as soon as a '\n' appears it creates a new line which is not allowed in your TextView and hence it appears as if it gets "truncated".

Maybe try removing that line singleLine constraint from your TextView?
- jwei

http://thinkandroid.wordpress.com
Examples, Code, and Tutorials
jwei512
Senior Developer
Senior Developer
 
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests