我有主widget
屏幕ListView
如何获得Item
被点击的当前数量:我尝试通过以下方式进行操作:Insite custom class which extends
AppWidgetProvider
public void onUpdate(Context ctxt, AppWidgetManager mgr,
int[] appWidgetIds) {
for (int i=0; i<appWidgetIds.length; i++) {
Intent svcIntent=new Intent(ctxt, WidgetService.class);
svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews widget=new RemoteViews(ctxt.getPackageName(),
R.layout.widget);
widget.setRemoteAdapter(appWidgetIds[i], R.id.contacts,
svcIntent);
Intent clickIntent=new Intent(ctxt, AppWidget.class);
clickIntent.setAction(ACTION_WIDGET_REFRESH);
clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds[i]);
PendingIntent pi=PendingIntent.getBroadcast(ctxt, 0 , clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
widget.setPendingIntentTemplate(R.id.contacts, pi);
mgr.updateAppWidget(appWidgetIds[i], widget);
}
super.onUpdate(ctxt, mgr, appWidgetIds);
}
@Override
public void onReceive(Context context, Intent intent) {
Log.i("gotcha","receive");
if (intent.getAction().equals(ACTION_WIDGET_REFRESH)) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
Bundle extras = intent.getExtras();
int extrass= -1;
if(extras!=null) {
extrass = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_IDS);
}
Log.i("receive", Integer.toString(extrass) ) ; // Here is I've expected to see Item ID
}
但这没有帮助。我刚刚看到不同的数字(不是项目 ID)
我怎样才能获得它们?