我有一个管理卡片视图的Recycler View Adapter。卡片上有一个按钮,可以启动另一项活动。
但是,出于某种原因,EXTRA_MESSAGE未被识别。我已经在我的主要活动中定义了它,所以我不确定问题是什么。这是代码:
@Override
public void onBindViewHolder(final View_Holder holder, final int position) {
//Use the provided View Holder on the onCreateViewHolder method to populate the current row on the RecyclerView
holder.name.setText(list.get(position).name);
holder.number.setText("Character # " + list.get(position).number);
holder.imageView.setImageBitmap(decodeSampledBitmapFromResource(context.getResources(), (list.get(position).imageId), 60, 60));
holder.fullbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, CardFullView.class);
intent.putExtra(Intent.EXTRA_MESSAGE, list.get(position));
context.startActivity(intent);
}
});
和MainActivity.java中的定义
public final static String EXTRA_MESSAGE = "com.package.name.MESSAGE";
答案 0 :(得分:2)
更改
Intent.EXTRA_MESSAGE
要
MainActivity.EXTRA_MESSAGE