Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android EXTRA_MESSAGE not recognized inside Recycler View Adapter

I have a Recycler View Adapter that manages Card Views. The cards have a button that should launch another activity.

However, for some reason EXTRA_MESSAGE isn't being recognized. I have defined it in my main activity, so I'm not sure what the problem is. Here is the code:

@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);
        }
    });

and the definition in MainActivity.java

 public final static String EXTRA_MESSAGE = "com.package.name.MESSAGE";
like image 716
Andy Avatar asked Oct 30 '22 00:10

Andy


1 Answers

Change

Intent.EXTRA_MESSAGE

To

MainActivity.EXTRA_MESSAGE
like image 142
W0rmH0le Avatar answered Nov 11 '22 11:11

W0rmH0le