[英]App Widget not displaying in ICS app drawer
有沒有人經歷過他們的app小部件未被列入ICS應用程序抽屜?
最初我開始使用FroYo及以下版本的應用程序,它支持app小部件就好了。 隨之而來的是Gingerbread和Honeycomb,這些也是如此。
如果我打開“小部件預覽”應用程序,小部件將出現在模擬器的列表中,但是當您打開抽屜時,它不會與其他小部件一起列出。 它確實出現在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
更新:
我今天早些時候發現的一條重要的logcat消息幫助我解決了這個問題:
06-01 14:41:31.606: E/AppsCustomizePagedView(199): Widget ComponentInfo{com.frankcalise.h2droid/com.frankcalise.h2droid.AppWidget} has invalid dimensions (108, 0)
我發現了這個問題。 我的appwidget-provider元素在其中一個屬性中有一個拼寫錯誤,應該說“minHeight”,而不是“maxHeight”。
讓我發現這一點的原因是從啟動器中找到logcat中的錯誤輸出。 它提到我的小部件具有無效的維度(因此它沒有將其添加到小部件列表中)。 然后我開始檢查與我的小部件相關的所有維度屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.