Data from a Selected RecyclerView

0

Good afternoon,

I need when someone clicks on an AnimeActivity data and is passed to the StartReport screen, could anyone help me?

insert the image description here

    
asked by anonymous 03.10.2018 / 20:36

1 answer

0

Hello, you are creating an AnimeActivity object, to receive the object that has been "serialized". Being that you sent the Anime object. Changes in line 28 of the Start Visit class:

Anime anime = (Anime) intent.getSerializableExtra("extra_anime");

-------------- EDIT

Sorry for the mistake, I had not tried that you are only passing a String to the Activity. Let's take advantage of it, to see if your code is actually passing the data and make sure we do not show any Exception :

txtContrato = (TextView) findViewById(R.id.txt_contrato); 
Intent intent = getIntent();
String anime = (String) getIntent().getSerializableExtra("extra_anime");
if (anime != null){
    txtContrato.setText(anime);
}

------ Update 05/10

If you can, copy the entire AnimeActivity code. For, by image, it generates much confusion. For example, the first and second image, are of the same stretch. However, the code is different.

If you want to send only the text, to the other Activity. In the third image, where is the call of the StartVisit. Line 57, change to:

String anime = tv_name.getText().toString();

But remember to change your putExtra signature "extra_anime". Well, it will make your code more complicated to read. Since this Activity is already receiving this same signature on an "anime" object.

That said, if you prefer, instead of just sending the String. You can remove this statement line and use the object declared in line 41 "anime". Take advantage of it to modify it to be a global class variable. To conclude, in the StartVisit and return to cast on line 28, to:

Anime anime = (Anime) intent.getSerializableExtra("extra_anime");
    
04.10.2018 / 16:56