2012-05-31 34 views
4

是否有人经历过他们的应用程序Widget未在ICS应用程序抽屉中列出?不显示在ICS应用程序抽屉中的应用程序小部件

本来我开始这个应用程序为FroYo和下面,它支持应用程序小部件就好了。一起来了姜饼和蜂窝,那些工作。

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

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

我会在下面发布一些片段,让我知道是否需要更多。我的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 

UPDATE:

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

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

回答

5

我发现这个问题。我的appwidget-provider元素在其中一个属性中存在拼写错误,应该说“minHeight”,而不是“maxHeight”。

是什么让我发现这是从发射器在logcat中发现错误输出。它提到我的小部件有无效的尺寸(因此它没有将它添加到小部件列表中)。于是我开始检查与我的小部件相关的所有维度属性。

相关问题