【问题标题】:App Widget not displaying in ICS app drawer应用程序小部件未显示在 ICS 应用程序抽屉中
【发布时间】:2012-09-25 19:21:25
【问题描述】:

是否有人遇到过他们的应用小部件未在 ICS 应用抽屉中列出?

最初我为 FroYo 及以下版本启动了这个应用程序,它很好地支持了应用程序小部件。随之而来的是 Gingerbread 和 Honeycomb,它们也很有效。

如果我打开“小部件预览”应用程序,小部件会出现在模拟器的列表中,但是当您打开抽屉时,它不会与其他小部件一起列出。它确实出现在蜂巢上。我也没有(其他人也没有)在我的 Galaxy Nexus 上看到它。

我已经尝试重新启动,因为我已经看到在初始安装后为某些人解决了问题。此外,我确实有一个带有 action.MAIN/category.LAUNCHER 意图过滤器的主要活动,因为我有应用程序活动,这不仅仅是一个小部件类型的项目。

我将在下面发布一些 sn-ps,如果需要更多信息,请告诉我。我的 minSdkVersion 为 7,targetSdkVersion 为 15,项目属性的目标也检查为 4.0.3。 installLocation 属性设置为 auto。

AndroidManifest.xml:

<receiver android:name=".AppWidget" android:label="@string/one_cell_widget_label">
    <intent-filter>
        <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
    </intent-filter>
    <intent-filter>
        <action android:name="com.frankcalise.h2droid.FORCE_WIDGET_UPDATE" />
    </intent-filter>
    <meta-data
        android:name="android.appwidget.provider"
        android:resource="@xml/one_cell_widget_settings" />
</receiver>

one_cell_widget_settings.xml:

<appwidget-provider
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:initialLayout="@layout/one_cell_widget"
    android:minWidth="@dimen/one_cell_widget"
    android:maxHeight="@dimen/one_cell_widget"
    android:updatePeriodMillis="0" >
</appwidget-provider>

one_cell_widget.xml:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widget_background"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="@dimen/widget_margin"
    android:background="@drawable/widget_background">
    <TextView
        android:id="@+id/widget_title_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/app_name"
        android:textColor="@android:color/black" />
    <TextView
        android:id="@+id/widget_amount_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/default_widget_amount"
        android:textSize="12sp"
        android:textColor="@color/amount_color" />
    <TextView
        android:id="@+id/widget_percent_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/default_widget_percent" />
</LinearLayout>

然后显然我在 AppWidget.java 中实现了这个类

public class AppWidget extends AppWidgetProvider

更新:

我今天早些时候发现的一条重要的 logcat 消息帮助我解决了这个问题:

06-01 14:41:31.606: E/AppsCustomizePagedView(199): Widget ComponentInfo{com.frankcalise.h2droid/com.frankcalise.h2droid.AppWidget} has invalid dimensions (108, 0)

【问题讨论】:

    标签: android android-4.0-ice-cream-sandwich android-appwidget


    【解决方案1】:

    我发现了问题。我的 appwidget-provider 元素的其中一个属性有错字,应该是“minHeight”,而不是“maxHeight”。

    导致我发现这一点的原因是在启动器的 logcat 中发现了错误输出。它提到我的小部件尺寸无效(因此它没有将其添加到小部件列表中)。于是我开始检查与我的小部件相关的所有维度属性。

    【讨论】:

      猜你喜欢
      • 2012-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-26
      • 2016-07-14
      • 1970-01-01
      • 2023-01-16
      • 1970-01-01
      相关资源
      最近更新 更多