以下代码创建一个小部件并将其添加到我的布局中。但无论是什么听众'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();
}