【问题标题】:How to select data from sqllite and show in TextView ( split text with @)如何从 sqlite 中选择数据并在 TextView 中显示(用@分割文本)
【发布时间】:2017-02-03 21:49:27
【问题描述】:

我用的是Android studio,这是我的sql语句

MYTABLE (id, data) VALUES (1,`ab@cdefg@higklmn@opq`);

我想在每个 TextView 值中显示数据并使用“@”拆分数据,而无需在我的 TextView 中显示“@”

像这样:

TextView1 = "ab"
TextView2 = "cdefg"
TextView3 = "higklmn"
TextView4 = "opq" 

谢谢

【问题讨论】:

  • 问题是......为什么不使用多列,而不是包含多个值的单个列?你认为你在做什么样的优化?
  • 抱歉我的问题。我是编程新手。

标签: java android sqlite android-studio


【解决方案1】:

从数据库中取出数据后,会收到类似的字符串

String result =  "ab@cdefg@higklmn@opq";
//Split it via @ using split function
String arrayOfResult = result.split("@");

就是这样。
现在运行一个循环并为您的 TexViews 分配一个值

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-19
    • 1970-01-01
    • 2017-12-20
    • 2012-08-31
    • 1970-01-01
    • 1970-01-01
    • 2018-03-11
    相关资源
    最近更新 更多