【问题标题】:How to get the text from array of textviews then store the getted text in a string array如何从 textviews 数组中获取文本,然后将获取的文本存储在字符串数组中
【发布时间】:2012-03-07 14:37:39
【问题描述】:

嗨,我正在开发一个 android 应用程序,我遇到了一个问题,比如我有 10 个文本视图,我需要获取每个文本视图文本并将该文本存储在字符串数组中。..

请帮助我..提前谢谢..

【问题讨论】:

  • textviews[0].getText().toString();
  • 实际上我在我的程序中调用了所有这些文本视图,就像这样 Integer[] Textview = { R.id.score_text_01, R.id.score_text_02, R.id.score_text_03, R.id.score_text_04, R .id.score_text_05, R.id.score_text_06, R.id.score_text_07, R.id.score_text_08, R.id.score_text_09, R.id.score_text_10 };
  • 当我试图用 textview 创建一个数组时,比如 final Textview[] text={} 它在 R.java 文件中抛出错误,这就是我创建一个整数数组的原因..
  • 你能解释一下你什么时候做 findViewById 吗?
  • 类似这样:private TextView displayTextView = (TextView)findViewById(R.id.DisplayTextView);,然后检索文本 displayTextView.gettext();

标签: android textview


【解决方案1】:
String s = textView.getText().toString();

【讨论】:

  • 这没关系,现在可以将其分配给字符串..还有一件事我需要验证该字符串(我已将其转换为整数数组)并将最高数字放在第一个 textview我该怎么做...提前谢谢...
  • 这可能会对您有所帮助。字符串 s[] = {"2","5","10"}; Arrays.sort(s); System.out.println(s[0]);
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-17
  • 1970-01-01
  • 2023-03-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多