【发布时间】:2013-01-31 21:34:05
【问题描述】:
我的小部件在加载小部件时出现问题,并且无法正常工作。
这是我在 logcat 输出中收到的输出,但我不确定它的含义。
W/de.vogella.android.widget.example(1613): onUpdate method called
W/AppWidgetHostView(412): updateAppWidget couldn't find any view, using error view
W/AppWidgetHostView(412): at android.appwidget.AppWidgetHostView.updateAppWidget(AppWidgetHostView.java:394)
W/AppWidgetHostView(412): at com.android.launcher2.LauncherAppWidgetHostView.updateAppWidget(LauncherAppWidgetHostView.java:54)
W/AppWidgetHostView(412): at android.appwidget.AppWidgetHost.updateAppWidgetView(AppWidgetHost.java:376)
W/AppWidgetHostView(412): at android.appwidget.AppWidgetHost$UpdateHandler.handleMessage(AppWidgetHost.java:101)
W/de.vogella.android.widget.example(1664): onUpdate method called
W/de.vogella.android.widget.example(1664): onUpdate method called
W/de.vogella.android.widget.example(1664): onUpdate method called
W/de.vogella.android.widget.example(1705): onUpdate method called
W/de.vogella.android.widget.example(1744): onUpdate method called
W/AppWidgetHostView(412): updateAppWidget couldn't find any view, using error view
W/AppWidgetHostView(412): at android.appwidget.AppWidgetHostView.updateAppWidget(AppWidgetHostView.java:394)
W/AppWidgetHostView(412): at com.android.launcher2.LauncherAppWidgetHostView.updateAppWidget(LauncherAppWidgetHostView.java:54)
W/AppWidgetHostView(412): at android.appwidget.AppWidgetHost.updateAppWidgetView(AppWidgetHost.java:376)
W/AppWidgetHostView(412): at android.appwidget.AppWidgetHost$UpdateHandler.handleMessage(AppWidgetHost.java:101)
W/de.vogella.android.widget.example(1744): onUpdate method called
W/AppWidgetHostView(412): updateAppWidget couldn't find any view, using error view
W/AppWidgetHostView(412): at android.appwidget.AppWidgetHostView.updateAppWidget(AppWidgetHostView.java:394)
W/AppWidgetHostView(412): at com.android.launcher2.LauncherAppWidgetHostView.updateAppWidget(LauncherAppWidgetHostView.java:54)
W/AppWidgetHostView(412): at android.appwidget.AppWidgetHost.updateAppWidgetView(AppWidgetHost.java:376)
W/AppWidgetHostView(412): at android.appwidget.AppWidgetHost$UpdateHandler.handleMessage(AppWidgetHost.java:101)
OnUpdate() 方法是使用服务触发的。我在下面发布了服务内容:
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
Log.w(LOG, "onUpdate method called");
// Get all ids
ComponentName thisWidget = new ComponentName(context,
MyWidgetProvider.class);
int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
// Build the intent to call the service
Intent intent = new Intent(context.getApplicationContext(),
UpdateWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds);
// Update the widgets via the service
context.startService(intent);
}
我认为问题出在布局上。如果我想将其更改为字幕文本,那么我会遇到这个问题。布局是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="8dip"
android:background="@drawable/myshape" >
<TextView
android:id="@+id/update"
android:layout_width="200dp"
android:duplicateParentState="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Loading... More text to see if it spans or not and want more" >
<requestFocus
android:duplicateParentState="true"
android:focusable="true"
android:focusableInTouchMode="true" />
</TextView>
</LinearLayout>
错误消息是什么意思,为什么我的小部件没有加载?
【问题讨论】:
-
任何源代码? onUpdate 方法可能是一个线索。
-
@StarsSky 请立即查看。正如我所说,问题出在我修改了 textview 以使其可以选择之后。
-
看看这个stackoverflow.com/a/3333855/2015318也许你能解决你的问题
-
@StarsSky 我关注了 (stackoverflow.com/questions/7868748/…),因为这是一个小部件。并且上一个链接的解决方案不起作用。