0
Good afternoon,
I need that when the person clicks on a take the data from Animeactivity and is passed to Start screen ?
0
Good afternoon,
I need that when the person clicks on a take the data from Animeactivity and is passed to Start screen ?
0
Hello, you are creating an Animeactivity object, to receive the object that was "Serialized". Since you sent the Anime object. Changes line 28 of class Start visit:
Anime anime = (Anime) intent.getSerializableExtra("extra_anime");
--------------EDIT
Sorry for the mistake, I had not attempted that you are just passing a String to Activity.
Let’s take advantage, to check if your code is really passing the dice and make sure to present none 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. Because, by image, it creates a lot of confusion. For example, the first and second images are from the same section. 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 from Homevisit. Line 57, change to:
String anime = tv_name.getText().toString();
But remember to change your signature from putExtra "extra_anime". Because, it will make your code more complicated to read. Since this Activity is already receiving this same signature, in an object "anime".
That said, if you prefer, instead of just sending String. You can remove this statement line and use the declared object in line 41 "anime". Take the opportunity to modify it to be a global variable of the class. To conclude, in Homevisit and return to cast on line 28, to:
Anime anime = (Anime) intent.getSerializableExtra("extra_anime");
Browser other questions tagged java android json android-layout
You are not signed in. Login or sign up in order to post.
Ai would be example: Intent Intent = getIntent(); Anime anime = (Anime) Intent.getSerializableExtra("extra_anime"); txtContract.setText(anime.getName());
– Ronaldo Amaral
YES. Just remember that setText will give Nullpointer if you have not declared the txtContract field. Using findViewById.
– Rodrigo Paixão
Esta dando esse erro: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.demotxt.myapp.RelatorioBR.model.Anime.getName()' on a null object reference
 at com.demotxt.myapp.RelatorioBR.visitas.IniciarVisita.onCreate(Initiate visit.java:39)
– Ronaldo Amaral
my code ta thus: txtContract = (Textview) findViewById(R.id.txt_contract); Intent Intent = getIntent(); Anime anime = (Anime) Intent.getSerializableExtra("extra_anime"); txtContract.setText(anime.getName());
– Ronaldo Amaral
Rodrigo good afternoon, now the code is working OK but has no value, I need you to take the anime.getName selected in Recycler View would be possible to talk via WPP or some other remote way for you to help me give a light ?
– Ronaldo Amaral