I working an App where In my MainActivity I added Toast message which display highest Loaded events.
e.g: In MainActivity
- Toast.makeText(this, "Load Events" + this.events.size(), Toast.LENGTH_LONG).show();
Now, Next part when above toast message appear on the MainActivity screen it will add that event into SecoendActivity Listview
- How do i add toast message event into second activity listview?
- will Mainactivity to SecondActivity?
Tuhin PaulPosted Mar 22, 2023, 1:37 AM
In SecondActivity, you can retrieve this event data from the Intent in the onCreate() method and add it to your ListView adapter. See how you can modify your SecondActivity code to achieve this:
This code retrieves the event data from the Intent in the onCreate() method using the key "event_data", adds it to the eventList list, and creates an ArrayAdapter with this list to set the adapter for the ListView.
Tuhin PaulPosted Mar 22, 2023, 1:35 AM
In MainActivity, after displaying the Toast message, add the following code to create an Intent and add the event data as an extra:
This code creates an Intent to start the SecondActivity, and adds the latest event data as an extra with the key "event_data".
Tuhin PaulPosted Mar 22, 2023, 1:34 AM
Hello Meggy,
To pass the event data from MainActivity to SecondActivity, you can use an Intent to start the SecondActivity and pass the event data as an extra.