android - Updating appWidget gives Problem loading gadget -
i'm trying add view main remoteviews keep getting problem loading gadget error. here's xmls , code, appreciated.
public class widgetprovider extends appwidgetprovider { @override public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { componentname thiswidget = new componentname(context, widgetprovider.class); remoteviews updateviews = new remoteviews(context.getpackagename(), r.layout.widget_main); remoteviews bookmark = new remoteviews(context.getpackagename(), r.layout.widget_items); updateviews.addview(r.id.view_container, bookmark); appwidgetmanager.updateappwidget(thiswidget, updateviews); }
}
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relativelayout_widget" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/widget_4x4_portrait" >
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content"> <linearlayout android:id="@+id/view_container" android:layout_width="fill_parent" android:layout_height="wrap_content"> <!-- new views added here @ runtime --> </linearlayout> </linearlayout>
note 2.1 has bug
appwidgetmanager.updateappwidget(int id, remoteviews rv)
does not work, must use
appwidgetmanager.updateappwidget(int [] ids, remoteview rv)
.
i made unit length array particular widget id
element.
weirdly, both methods work in 1.6, 2.0, 2.2 , 2.3
.
just pointer else stuck non updating appwidgets
.
Comments
Post a Comment