AppWidgetHostView忽略焦点和侦听器

时间:2013-06-11 13:47:17

标签: android android-widget launcher appwidgetprovider

以下代码创建一个小部件并将其添加到我的布局中。但无论是什么听众'OnLongClick'或'OnFocus'......我都加入'hostView',没有人会触发。 'hostView'也会忽略'setFocusable(false)'。有没有人知道如何从主机视图向Widget添加监听器?

public void createWidget(Intent data) {
    Bundle extras = data.getExtras();
    int appWidgetId = extras
            .getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
    AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager
            .getAppWidgetInfo(appWidgetId);
    final AppWidgetHostView hostView = mAppWidgetHost.createView(this,
            appWidgetId, appWidgetInfo);
    hostView.setAppWidget(appWidgetId, appWidgetInfo);
    ((LinearLayout) findViewById(R.id.widgetHolder)).addView(hostView);
    ((ImageButton) findViewById(R.id.bApps)).requestFocus();
}

0 个答案:

没有答案