应用的Widget在ICS应用程序的抽屉不显示 [英] App Widget not displaying in ICS app drawer

查看:227
本文介绍了应用的Widget在ICS应用程序的抽屉不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人经历了应用程序窗口小部件不会在ICS应用程序的抽屉被列?

本来我开始这个程序的升级Froyo及以下,支持应用程序部件就好了。来了姜饼和蜂窝,那些工作了。

小部件,如果我打开窗口小部件preVIEW应用程序出现在模拟器列表中,但是当你打开它不与其他上市的抽屉里。它不会出现在蜂窝。我没有(和其他人都没有也可以)看到它在我的Galaxy Nexus的任何地方无论是。

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

下面我将发布一些片段,让我知道,如果需要更多。我的minSdkVersion是7和targetSdkVersion月15日,项目属性也有目标在4.0.3检查。该的installLocation属性设置为自动。

AndroidManifest.xml中:

 <接收机器人:AppWidgetNAME =机器人:标签=@字符串/ one_cell_widget_label>
    &所述;意图滤光器>
        <作用机器人:名字=android.appwidget.action.APPWIDGET_UPDATE/>
    &所述; /意图滤光器>
    &所述;意图滤光器>
        <作用机器人:名字=com.frankcalise.h2droid.FORCE_WIDGET_UPDATE/>
    &所述; /意图滤光器>
    &所述;元数据
        机器人:名字=android.appwidget.provider
        机器人:资源=@ XML / one_cell_widget_settings/>
< /接收器>

one_cell_widget_settings.xml:

 < appwidget提供商
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:initialLayout =@布局/ one_cell_widget
    安卓了minWidth =@扪/ one_cell_widget
    安卓了maxHeight =@扪/ one_cell_widget
    机器人:updatePeriodMillis =0>
< / appwidget提供商>

one_cell_widget.xml:

 <的LinearLayout
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / widget_background
    机器人:方向=垂直
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:填充=@扪/ widget_margin
    机器人:背景=@绘制/ widget_background>
    <的TextView
        机器人:ID =@ + ID / widget_title_text
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:文字=@字符串/ APP_NAME
        机器人:文字颜色=@机器人:彩色/黑白/>
    <的TextView
        机器人:ID =@ + ID / widget_amount_text
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:文字=@字符串/ default_widget_amount
        机器人:TEXTSIZE =12SP
        机器人:文字颜色=@色/ amount_color/>
    <的TextView
        机器人:ID =@ + ID / widget_percent_text
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:文字=@字符串/ default_widget_percent/>
< / LinearLayout中>

和那么显然我实现了类AppWidget.java

 公共类AppWidget扩展AppWidgetProvider

更新:

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

  14 06-01:41:31.606:E / AppsCustomizePagedView(199):小部件ComponentInfo {com.frankcalise.h2droid / com.frankcalise.h2droid.AppWidget}具有无效尺寸(108 ,0)


解决方案

我发现这个问题。我appwidget提供商元素的属性之一错字,应该说了minHeight,而不是了maxHeight。

什么导致我发现,这是在寻找一个logcat中错误输出从启动。它提到了我的小部件有无效的尺寸(因此它并没有将它添加到小部件的列表)。于是我开始检查所有与我的插件的维度属性。

Has anyone experienced their app widget not being listed in the ICS app drawer?

Originally I started this app for FroYo and below, which supports the app widget just fine. Along came Gingerbread and Honeycomb, those work too.

The widget appears in the list in the emulator if I open up the "Widget Preview" app, however when you just open the drawer it isn't listed with the others. It does appear on Honeycomb. I don't (and others haven't also) see it on my Galaxy Nexus anywhere either.

I've tried rebooting as I've seen that solving the problem for some people after initial installation. Also I do have a main activity with the action.MAIN/category.LAUNCHER intent filter since I have app activities, this isn't a widget only type of project.

I'll post some snippets below, let me know if more is needed. My minSdkVersion is at 7 and targetSdkVersion at 15, project properties also has the target checked at 4.0.3. The installLocation attribute is set to 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>

and then obviously I implemented the class in AppWidget.java

public class AppWidget extends AppWidgetProvider

UPDATE:

An important logcat message I found earlier today which helped me solve the issue:

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

解决方案

I found the issue. My appwidget-provider element has a typo in one of the attributes, it should say "minHeight", not "maxHeight".

What lead me to finding this was finding an error output in logcat from the launcher. It mentioned my widget had invalid dimensions (therefore it didn't add it to the list of widgets). So then I started checking all the dimension attributes related to my widget.

这篇关于应用的Widget在ICS应用程序的抽屉不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆