0

I'm trying to create a button that could add another item to my listview automatically. So when people click on the button they add a new window to the list.

So for example.

List: Object 1 Object 2 Object 3 Object 4 Object 5 Object 6

Clicks on button to add a new item Object 1 Object 2 Object 3 Object 4 Object 5 Object 6 Object 7

Keep in mind this button is in another activity window.

So a button from another activity adds to a list.

how do you do that in android studio?

Isaiah Reid
  • 19
  • 1
  • 2
  • Only one activity can be active. I would save the data in SQLite or pass it from one activity to another with an Intent/Bundle. Here is one example of passing data with an Intent: http://www.101apps.co.za/index.php/articles/passing-data-between-activities.html – Al Lelopath Apr 08 '16 at 17:27
  • Use broadcast receiver – Sabeer Apr 08 '16 at 17:34

1 Answers1

0

You could store your information in array which can be stored in shared preferences or in a database, on every click of the button the shared preference or the database can be updated. In the second activity where your listview is present the data can be retrieved from ,again, the shared preference or the database. I could have helped you with the code if you were more specific on what you want. PS: You could also use intent to simply pass your data from on activity to another. Here is a similar question - How to pass objects from one activity to another

You could modify this to suit your needs and pass an array of objects.

Community
  • 1
  • 1
IBSiC
  • 1
  • 2