2012-05-31 83 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中發現錯誤輸出。它提到我的小部件有無效的尺寸(因此它沒有將它添加到小部件列表中)。於是我開始檢查與我的小部件相關的所有維度屬性。

相關問題