在Recycler View Adapter中无法识别Android EXTRA_MESSAGE

时间:2016-07-04 17:27:43

标签: java android android-intent

我有一个管理卡片视图的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";

1 个答案:

答案 0 :(得分:2)

更改

Intent.EXTRA_MESSAGE

MainActivity.EXTRA_MESSAGE