我有一个我正在使用的小部件,它允许用户在屏幕上有更多的小部件实例。 每个部件id维护自己的配置文件。 然而对于一些为每个小部件to设置按钮的代码,我的代码都不起作用。 下面是负责的代码。 谁能看到问题在哪里?
private void TieClicks(Context context){
RemoteViews rViews;
PendingIntent editPendingIntent= null;
//Intent updateintent = new Intent(context,SyncNoteWidget.class);
//updateintent.setAction(SyncNote_Action_Widget_Update);
//PendingIntent pendingupdateintent = PendingIntent.getBroadcast(context, 0, updateintent, 0);
//rViews.setOnClickPendingIntent(R.id.widgettextview, pendingupdateintent);
//
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] ids = appWidgetManager.getAppWidgetIds(new ComponentName(context, SyncNoteWidget.class));
for (int i =0;i <ids.length;i=i+1){
int wId = ids[i];
rViews = new RemoteViews(context.getPackageName(),R.layout.widget);
editPendingIntent = makeControlPendingIntentActivity(context, wId);
Log.v("syncnote","tieing" + String.valueOf(wId));
rViews.setOnClickPendingIntent(R.id.widgeteditbutton, editPendingIntent);
appWidgetManager.updateAppWidget(wId, rViews);
editPendingIntent= null;
}
}
private PendingIntent makeControlPendingIntentActivity(Context context,int appWidgetId) {
Intent active = new Intent(context, EditNote.class);
active.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
active.setAction(com.ntu.way2fungames.syncnote.SyncNoteWidget.SyncNote_Action_Edit);
active.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
return(PendingIntent.getActivity(context, 0, active, 0 ));
}