【发布时间】:2012-01-09 20:44:14
【问题描述】:
我有一个针对 Android 2.1 创建的小部件,它很好并且在市场上销售。
我有一个用户抱怨他买了它,但它从未出现在他的 Android 4.0 设备上。
我加载了 4.0 模拟器,从 Eclipse 运行它,它报告安装成功,实际上我可以在“Widget Preview”应用程序中看到它,我可以在那里运行它,看起来不错,但它没有'没有出现在“小部件”下的任何地方——我实际上找不到它来将它拖到主屏幕上!我认为这与用户看到的内容相同。
知道这里发生了什么吗? 为什么在 2.1 中可以正常安装,但在 4.0 中没有出现在列表中,即使安装成功?
这是我的 layout\widget.xml 文件,如果有帮助的话:
<RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:layout_width="wrap_content" android:id="@+id/blankspot" android:layout_height="5dp" android:gravity="center" android:shadowDy="1" android:shadowDx="1" android:layout_centerHorizontal="true"></TextView>
<ImageButton android:layout_below="@+id/blankspot" android:layout_width="60dp" android:layout_height="60dp" android:id="@+id/widgetIconButton" android:layout_centerHorizontal="true" android:scaleType="centerCrop" android:src="@drawable/volumeprofilesplus" android:background="@null"></ImageButton>
<ImageView android:layout_width="60dp" android:layout_height="20dp" android:id="@+id/override" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:scaleType="fitXY" android:background="@null" android:src="@drawable/overredcaps" android:visibility="invisible"></ImageView>
<ImageButton android:layout_below="@+id/widgetIconButton" android:layout_width="70dp" android:layout_height="30dp" android:id="@+id/widgetSettingsButton" android:layout_centerHorizontal="true" android:scaleType="fitXY" android:src="@drawable/settings" android:background="@null"></ImageButton>
</RelativeLayout>
还有 xml\widget_provider.xml:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="72dip"
android:minHeight="72dip"
android:updatePeriodMillis="0"
android:initialLayout="@layout/main" >
</appwidget-provider>
【问题讨论】:
-
请发布您的 {widget}.xml
-
清单或提供者 xml?让我弄清楚如何正确粘贴代码...
-
layouts\widget.xml- 这是一个“错字”还是您的提供者 xml 真的在布局文件夹中?应该在res/xml/widget.xml。 -
是的,糟糕,粘贴了错误的东西。修好了。我也可以发布清单,但它相当冗长。我在我的 Thunderbolt (2.3.4) 上运行良好,它显示在下载列表中并且实际上正在运行,但我看不出有办法将它带到桌面上。我在 4.0 模拟器上滚动了所有小部件列表,但它没有显示出来。
-
呃。嗯。所以它只是在我重新启动设备后出现。所以我想答案是“有时你必须重启你的设备”?我暂时把这个问题留作一个问题,以防我的 XML 中真的有我应该有的东西。
标签: android widget android-4.0-ice-cream-sandwich