在 RemoteViews 中的 EmptyView 上设置 onClickListener

Set onClickListener on EmptyView in RemoteViews

我用 listView 制作了 appWidget。为此,我需要使用 RemoteViews。当我初始化 appWidget ListView 时,我设置了适配器和空视图(当没有内容时):

remoteViews.setEmptyView(R.id.listViewWidget, R.id.empty_view);

但是我的emptyView包含按钮,我需要为它设置OnClickListener。我该怎么做?

你需要 setOnClickPendingIntent.

remoteviews.setOnClickPendingIntent(button_id, pendingIntent);

More Info