如何在 appwidgetprovider 中查找视图 ID? [英] How to find view id in appwidgetprovider?

查看:28
本文介绍了如何在 appwidgetprovider 中查找视图 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从 appwidgetprovider 扩展的 appwidget.

I have a appwidget extends from appwidgetprovider.

我创建了一个名为 main_layout.xml 的布局 xml 文件并添加了一个按钮.如果我开发一个 listActivity,我会通过以下路径到达此按钮:R.layout.main_layout.button01.

I have created a layout xml file named main_layout.xml and add a button. If i develop a listActivity i reach this button with this path: R.layout.main_layout.button01.

(Button)findViewById(R.layout.main_layout.button01)

Activity 类有一个名为 findViewById() 的成员方法,但 appwidgetprovider 没有.

Activity class has a member method that named findViewById() but appwidgetprovider has not.

如何到达布局中的按钮?

How can i reach my button in my layout?

对不起我的英语

推荐答案

您永远不能直接在 Appwidget 中引用或修改视图.您应该在 RemoteViews 中执行此操作.

You can never reference or modify views in Appwidget directly. You should do this in RemoteViews.

这篇关于如何在 appwidgetprovider 中查找视图 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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