简体   繁体   中英

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";

Change

Intent.EXTRA_MESSAGE

To

MainActivity.EXTRA_MESSAGE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM