我想添加一個視圖到我的主RemoteViews,但我不斷收到問題加載小工具錯誤。這裏是xml和代碼,一些幫助將不勝感激。更新appWidget給問題加載小工具
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 will be added here at runtime -->
</LinearLayout>
</LinearLayout>
什麼是錯誤?你可以把堆棧跟蹤嗎? – Nanis 2011-02-24 08:10:02
小部件不顯示,而是顯示小部件應該顯示在何處的問題加載小部件。 Log.e沒有顯示(我沒有用我自己的Log進行測試,因爲我不知道要測試什麼) – lpandzic 2011-02-24 08:17:53