10

I have following data in my db row:

Espresso:                           7,00

Double Espresso:                    8,00

Ristretto:                          7,00

Espresso Machiato:                  8,00

Espresso Con Panna:                 8,00

I write it on Word, then copy & paste to MySQL editor. When I save it, my IOS and Android apps cannot show the prices aligned because of the tab characters.

enter image description here

What is the best way to do that?

Burak
  • 5,706
  • 20
  • 70
  • 110

4 Answers4

6

The best way- those 2 things are different data and are in different columns in your database, I would expect (if not, you need to fix your schema). So put the 2 strings in separate TextViews, and align the text view in xml.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • It's not possible for now due to my schema. – Burak Jul 08 '14 at 10:27
  • 1
    if you can't split them due to your schema you can always parse the text, and use separated TextViews as @Gabe Sechan recommends or maybe use a [TabStop] (http://developer.android.com/reference/android/text/style/TabStopSpan.html) span see also http://stackoverflow.com/questions/19121125/using-span-to-insert-tab-in-textview – forcewill Sep 03 '15 at 12:59
3

First you can split the data from tab character and use formatting like below in java. I believe in objective-c it should be similar.

    String ehe = String.format("%-20s : \t %4dTL \n","ehemehe",23);
    String ehe2 = String.format("%-20s : \t %4dTL \n","ehemeheadawd",44);
    System.out.println(ehe);
    System.out.println(ehe2);

Output it produces is

ehemehe              :     23TL 

ehemeheadawd         :     44TL
DreadfulWeather
  • 716
  • 3
  • 13
1

replace the "/t" chars with "" before you display the text. by using

String.replace("/t","");
Ercan
  • 3,705
  • 1
  • 22
  • 37
0

Use a fixed-width font if you have precalculated the number of spaces.

Rick James
  • 135,179
  • 13
  • 127
  • 222