Best way to display multi-line data in a textview

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

Best way to display multi-line data in a textview

Postby BGH » Sun Mar 22, 2009 11:43 am

I have a layout which is a table layout with some textviews in the tablerows.

I want to display multiple lines of data in the textviews. At the moment I am just setting the textview to a String and the string contains new line characters. Such as

displayString = "Joe Bloggs" + "n" + "Henry Smith;

etc etc

The problem is that when I do this the second line is indented slightly compared to the first. It's only slight but it is quite annoying. If you look in the screenshot I have provided you will see that the second name in the list of names is always slightly indented.

Is there a better way I should be doing this? One thing I could do is have them as table rows which are created dynamically but I just thought I'd see if someone has a simple solution to the textview problem first.
Attachments
emulator.jpg
emulator.jpg (51.45 KiB) Viewed 289 times
User avatar
BGH
Junior Developer
Junior Developer
 
Posts: 23
Joined: Thu Feb 12, 2009 3:51 am
Location: Melbourne, Australia

Top

Postby BGH » Mon Mar 23, 2009 9:18 am

Dont worry. I have solved this one. It came down to a quirk in the source data I am sourcing from a webpage. For some reason they post the first name fine and all the rest with a leading and trailing space.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <tr>
  2.  
  3.                 <th scope="row">Michael Bani</th>
  4.  
  5.                 <td> 7m</td>
  6.  
  7.             </tr>
  8.  
  9.            
  10.  
  11.             <tr>
  12.  
  13.  
  14.  
  15.                 <th scope="row"> Jamie Lyon </th>
  16.  
  17.                 <td>11m</td>
  18.  
  19.             </tr>
  20.  
  21.            
  22.  
  23.             <tr>
  24.  
  25.                 <th scope="row"> Andrew Suniula </th>
  26.  
  27.                 <td>46m</td>
  28.  
  29.  
  30.  
  31.             </tr>
  32.  
  33.            
  34.  
  35.             <tr>
  36.  
  37.                 <th scope="row"> Adam Cuthbertson </th>
  38.  
  39.                 <td>49m</td>
  40.  
  41.             </tr>
  42.  
  43.            
  44.  
  45.             <tr>
  46.  
  47.                 <th scope="row"> Jamie Lyon </th>
  48.  
  49.  
  50.  
  51.                 <td>58m</td>
  52.  
  53.             </tr>
  54.  
  55.  
Parsed in 0.004 seconds, using GeSHi 1.0.8.4


A simple String.trim() sorted it all out.
User avatar
BGH
Junior Developer
Junior Developer
 
Posts: 23
Joined: Thu Feb 12, 2009 3:51 am
Location: Melbourne, Australia

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google [Bot] and 5 guests