get text of a TextView in android home widget (not in activity)?(在 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 的文本(不在活动中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 android home 小部件中获取 TextView 的文本(不在活动中)?
基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
