I have a method in a Fragment that takes a value from a quantity Spinner and returns it. Where can I retrieve the value of this variable? If I want to move it to a new Activity altogether, how can I retrieve it there?
public String SetupQuantitySpinner(String[] quantity) {
Spinner spnr2;
spnr2 = (Spinner)view.findViewById(R.id.spinner_quantity);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
getActivity(),
R.layout.custom_spinner,
R.id.text_main_seen,
quantity);
spnr2.setAdapter(adapter);
return quantity[spnr2.getSelectedItemPosition()];
}
Basically the Spinner represents the quantity of the item that a user has decided to purchase, i.e. 1 to 20 shirts. I now have to multiply this value by its cost, but the cost is retrieved in another Activity altogether:
String cost = currentProduct.getCost();
I need to send quantity[spnr2.getSelectedItemPosition()]
to this new Activity so that I can multiply it by currentProduct.getCost();
How can I accomplish this?
Edit: This is different and hence not a duplicate because I only want to send and retrieve data associated with the selected Spinner item.