android - 为什么我的 AppWidget 没有使用提供的标签?

标签 android android-widget

我已经在 XML 应用程序小部件提供程序中指定了 android:label,但是当您执行 Home->Widgets->... 时,指定的名称没有被使用,而是使用应用程序的名称,如果没有则使用默认值提供标签。配置中的尺寸被正确使用。

<appwidget-provider
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:initialLayout="@layout/widget_layout"
    android:minWidth="146dp"
    android:minHeight="146dp"
    android:label="@string/widget_title"
    android:updatePeriodMillis="21600000"
    >
</appwidget-provider>

然后在我的资源中:

<string name="widget_title">My Widget Name</string>

widget XML config 中引用的字符串资源已被IDE 验证,为什么没有使用字符串资源?

最佳答案

您需要在 receiver 部分的 AndroidManifest.xml 中为您的小部件指定 android:label="@string/widget_title"

不在 widget_info.xml 中的 appwidget-provider 中。

关于android - 为什么我的 AppWidget 没有使用提供的标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5555630/

相关文章:

Android 无法使用 Volley 库访问 URL

android - 如何获取某一列中具有相同值的行列表?

android - 按顺序显示多个按钮动画——只显示最后一个

android - 小部件和主应用程序之间的关系?

android - 编辑文本框中提示的自定义位置。

android - 为什么我的 SQL 服务器不能正常工作(android SDK)?

java - 从 url 加载图像

android - 将多个 View 添加到 LinearLayout 的最快方法是什么?

java - java.lang.Package.getDeclaredAnnotations 上 UnsatisfiedLinkError 的极其简化的测试用例

android - 如何对齐 ActionBar 中的菜单项