0

When I want to update my ImegeView, i see "Problem loading widget";

My main.xml

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout  xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="280dp"
android:layout_height="120dp"
android:background="@drawable/widget_bg"
>
<ImageView
android:name="@+id/image_in_widget"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</AbsoluteLayout>

My Widget.java

package endoftheworld.wid;
//some imports

public class Widget extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[]   appWidgetIds)
{
 RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.main); 
 Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.pulse);
 updateViews.setImageViewBitmap(R.id.image_in_widget,bitmap);
 appWidgetManager.updateAppWidget(appWidgetIds, updateViews);
 super.onUpdate(context, appWidgetManager, appWidgetIds); 
  }
}

In DDMS I can see

AppWidgetHostView(128): android.widget.RemoteViews$ActionException: can't find view: 0x7f060000

But I have 0x7f060000 in R.java

 //....
public static final class id {
    public static final int image_in_widget=0x7f060000;
}
 //...

I using Android Platform 2.3.1 API Level 9 CPU/ABI ARM (armeabi).

What's a trick?

David Hedlund
  • 128,221
  • 31
  • 203
  • 222
otopba
  • 214
  • 1
  • 6
  • 14

1 Answers1

0

The R.layout.main layout you're passing to RemoteViews doesn't have any view with the ID R.id.image_in_widget. Perhaps you meant to pass a different layout, or perhaps the ImageView in that layout has the wrong ID.

Dan Hulme
  • 14,779
  • 3
  • 46
  • 95