我一直在尝试创建一个基本的应用小部件,但无法让它显示在小部件列表中。
代码如下:
Widget_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dip"
>
<TextView
android:id="@+id/update"
style="@android:style/TextAppearance.Medium"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:resizeMode="horizontal|vertical"
android:gravity="center_horizontal|center_vertical"
android:layout_margin="4dip"
android:text="@string/click_to_configure" >
</TextView>
</LinearLayout>
小部件信息.xml:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minHeight="72dp"
android:minWidth="146dp"
android:updatePeriodMillis="1000"
android:initialLayout="@layout/widget_layout"
android:resizeMode="horizontal|vertical"
android:initialKeyguardLayout="@layout/widget_layout"
android:widgetCategory="keyguard|home_screen"
android:configure="com.promethylhosting.countdowntowidget.SettingsActivity"
/>
显现:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.promethylhosting.countdowntowidget"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".SettingsActivity"
android:icon="@drawable/ic_launcher"
android:label="Countdown to... Widget">
<intent-filter>
<action android:name=".ACTION_WIDGET_CONFIGURE"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- mulitple actions must have multiple action filters 1:1 ratio between action/filter -->
</activity>
<reciever
android:name="CountdownToWidgetProvider"
android:icon="@drawable/ic_launcher"
android:label="Countdown To Widget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</reciever>
</application>
</manifest>
我一直在谷歌搜索,并没有找到解决这个问题的任何解决方案。所以我在这里发帖。
提前感谢您阅读本文和建议。
编辑:还有其他建议吗?