Reputation: 4077
I'm trying to create a widget for Android. It contains such files:
res/xml/widgetinfo.xml:
<?xml version="1.0" encoding="UTF-8"?>
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="146dip"
android:minHeight="146dip"
android:updatePeriodMillis="3600000"
android:initialLayout="@layout/main" />
res/layout/main.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout >
<TextView android:text="My widget" />
</LinearLayout>
</FrameLayout>
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.justmad.thegame"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<receiver android:name="WidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widgetinfo" />
</receiver>
</application>
</manifest>
src/com.test.WidgetProvider:
package com.test;
import android.appwidget.AppWidgetProvider;
public class WidgetProvider extends AppWidgetProvider {
}
But when I run it in AVD and trying to add my widget it displays the message "Problem loading widget". LogCat shows nothing in verbose mode. So, what is wrong?
Upvotes: 0
Views: 400
Reputation: 1006664
You need to implement onUpdate()
in your AppWidgetProvider
.
Your layout does not work. You could tell this by trying your layout in, say, an activity. You are missing android:layout_width
and android:layout_height
on the LinearLayout
and the TextView
. Also, it is unclear what your FrameLayout
is doing for you.
Upvotes: 1