在 android home 小部件中获取 TextView 的文本(不在活动中)? [英] get text of a TextView in android home widget (not in activity)?

查看:21
本文介绍了在 android home 小部件中获取 TextView 的文本(不在活动中)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用 android home 小部件进行编程,所以我可以通过 settextviewtext() 从我的小部件提供程序将文本设置为 home 小部件中的 textview,但是当我想从中获取文本时,我没有理想.不能像在活动中一样正常使用 findViewById(),然后使用 getText().有没有办法从小部件提供者那里获取主页小部件中的 textview 文本?或者告诉我如何从另一个活动中获得?

I just begin programming with android home widget, so i could set text to a textview in home widget from my widget provider by settextviewtext() but when i want to get text from it, i have no ideal. Can not use findViewById() as normal as in activity and then getText(). Is there any way to get text of textview in home widget from widget provider? Or show me how to get from another activity?

推荐答案

CommonsWare in这个问题说:

你不能.应用程序小部件是只写的:您可以将数据推送给它们,但是你无法阅读它们.

You can't. App widgets are write-only: you can push data to them, but you cannot read them.

相反,当您使用新文本更新应用小部件时,您需要将该文本存储在某个地方,也许是在一个文件中.

Instead, when you update your app widget with new text, you will need to store that text somewhere, perhaps in a file.

这篇关于在 android home 小部件中获取 TextView 的文本(不在活动中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆