【问题标题】:get text of a TextView in android home widget? [duplicate]在 android 主页小部件中获取 TextView 的文本? [复制]
【发布时间】:2012-06-27 09:41:59
【问题描述】:

我刚开始使用 android home 小部件进行编程,所以我可以从我的小部件提供程序将文本设置为 home 小部件中的 textview,但是当我想从中获取文本时,我没有理想。无法 findById() 和 getText()。有没有办法从小部件提供者那里获取主页小部件中的 textview 文本?或者告诉我如何从另一个活动中获得?

【问题讨论】:

标签: android widget gettext


【解决方案1】:

她是示例代码。

TextView textValue = (TextView) layout.findViewById(R.id.labelValue);
String s = textValue.getText().toString();
textValue.setText("Welcome");

【讨论】:

  • 天啊,请再次阅读我的问题。我在小部件提供程序中找不到 ViewById。这是我第一次使用小部件进行编程,我发现无法findViewById,所以我在获取TextView并获取文本时卡住了。
猜你喜欢
  • 1970-01-01
  • 2012-02-10
  • 1970-01-01
  • 2012-04-02
  • 1970-01-01
  • 2021-07-09
  • 2015-04-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多