简体   繁体   English

如何在Android和IOS应用程序中正确显示来自MySQL数据库的选项卡(空白)?

[英]How to display tabs(whitespace) coming from MySQL database correctly on both in Android and IOS app?

I have following data in my db row: 我在db行中有以下数据:

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. 我在Word上编写它,然后复制并粘贴到MySQL编辑器。 When I save it, my IOS and Android apps cannot show the prices aligned because of the tab characters. 当我保存它时,由于标签字符,我的IOS和Android应用程序无法显示价格对齐。

在此输入图像描述

What is the best way to do that? 最好的方法是什么?

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. 因此,将2个字符串放在单独的TextView中,并将文本视图与xml对齐。

First you can split the data from tab character and use formatting like below in java. 首先,您可以从制表符分割数据,并在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

replace the "/t" chars with "" before you display the text. 在显示文本之前用“”替换“/ t”字符。 by using 通过使用

String.replace("/t","");

如果您预先计算了空格数,请使用固定宽度的字体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM