El widget no está cargado en AVD

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?

preguntado el 09 de marzo de 12 a las 16:03

1 Respuestas

  1. Necesitas implementar onUpdate() en tu AppWidgetProvider.

  2. Your layout does not work. You could tell this by trying your layout in, say, an activity. You are missing android:layout_width y android:layout_height al LinearLayout y TextView. Also, it is unclear what your FrameLayout está haciendo por ti.

respondido 09 mar '12, 17:03

Setting layout helped, thank you! I thought it has default values if not set directly... - solo_loco

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.