I am writing an android app and in my main activity I have a group of 5 buttons. Essentially, I would like to assign different prices for an enumeration depending on the button selected.
In my third activity, I would like to utilize the prices set in the enumeration in global data to calculate the transactions. In the first activity, you select a button based on what store you want.
This would indicate which pricing group to use for a set list of objects. Then in the third activity, you would select the items and the price would be associated with it.
Then the final activity will sum up the total and give a summary. How can I assign the prices in an enumeration in global data based on the button selected.
And how can I assign prices to the third activity based on the button/store selected?
Asked
Active
Viewed 36 times
0

Parth Lotia
- 753
- 1
- 7
- 25

kahare
- 1
- 2
1 Answers
0
Either you can pass the value from 1st activity to 2nd activity and then from 2nd activity to 3rd using Intents
.
For passing data between activities read this.
or
You can set the selected value in SharedPreference
on selection from 1st screen and read that value in your third activity. (This method will persist the value) For SharedPreference demo follow this.
One another way is, you can create a Singleton Class
to maintain the status of whatever variable you want. Set the value from 1st activity and get it from the same class in your 3rd activity. For Singleton class

Nitesh
- 3,868
- 1
- 20
- 26