Dirk Lucas wrote:Hello!
I am currently trying to create a minor android app. Hoping to learn from it while doing it. Now I stumbled upon the following problem: I wan't to make a new activity. Like the one in the third codeblock. However, this activity should show a listview with 3 listview-buttons, one for minimal, medium and maximum.
To clarify: the user will get a listview (this one works already) than select one button from this listview and he goes to the next activity with another Listview which has the 3 problematic buttons filled with the variables maximum, medium and minimal.
Problem is, I do not now how to get this done. I am still learning and I do not see how I can extract these 3 parameters from the items in the List<FoodTimes> and showcase ehm. Mostly because the toString method in the FoodTimes class returns a name. How the heck do I make it so that this class returns OR the name OR minimal, medium & maximum (without me getting a list of hashcodes instead of Strings) ?
I have created a class which provides and arraylist:
a class which defines the items in the list:
And a class which shows the first parameter of the FoodTimes objects in a listview:
And lastly my attempt: --> which does not work because I do not see how I can get the right data in the String array (and I doubt if I am even in the right direction. I hope you understand what I am trying to ask as I feel my head is wuzzling and things aren't super clear atm:P Thanks in advance for any help!
I don't 100% know what it is you're trying to do, but I understand that you're trying to allow the user to press one button from a listview (Which you already have working), which then takes them to another listview with 3 buttons which have written on them the 3 variables (maximum, medium and minimal)?
If I'm correct, then all you need to do to pass the variables to the new activity which displays the 3 buttons is use an intent.
Just do something like this:
then in your activity which has the three buttons you need to call getIntent() to obtain the variables.
so something like this
and just do the same for the other variables too.
Make sure you call getIntent() within the onCreate method. You can declare the variables as instance variables, but when you want to assign the variables using getIntent() make sure you do that within the onCreate method.
Once you have the variables you just need to add the code to make the buttons display them.
I'm not sure whether I answered your question or not but I hope this helped lol.