0
发送额外
我呈现在一个循环控件项目攻我要开始DetailsActivity后(它应该发送ID到活动)Android的 - 通过的PendingIntent
Cursor currentCursor = dbHelper.getWidgetCursor();
for(int k=0; k < currentCursor.getCount(); k++){
currentCursor.moveToPosition(k);
RemoteViews rw = new RemoteViews(context.getPackageName(), R.layout.w_calendar_item);
Intent intentRow = new Intent(context, DetailsActivity.class);
Log.v("a", "index: "+currentCursor.getInt(currentCursor.getColumnIndex(SqlHelper.COLUMN_ID)));
intentRow.putExtra("index", currentCursor.getInt(currentCursor.getColumnIndex(SqlHelper.COLUMN_ID)));
PendingIntent pendingIntentRow = PendingIntent.getActivity(context, 1, intentRow, PendingIntent.FLAG_CANCEL_CURRENT);
rw.setOnClickPendingIntent(R.id.w_li, pendingIntentRow);
views.addView(R.id.w_list, rw);
}
我的问题是DetailsActivity总是收到指数103(其是列表中的最后一个)无关紧要哪个项目
那是因为你一次又一次地取消了以前的待决意图。考虑在“intentRow”中生成“独特”的内容 - 例如传递给'Intent#setData(Uri)'的虚假'Uri'会做诀窍 - 使用一条递增路径或一些像这样的愚蠢行为。 – Jens