I have two spinner in my system. Now I have to change the selected value of the 2nd spinner depending on the first spinner value. As soon as the user will change the 1st spinner value, the 2nd spinner value will set automatically depending upon the 1st spinner's selected value. How to implement this?
i have 2 EditText Boxes and 2 spinner. when i input values i开发者_开发技巧n edit boxes and if i select another spinner then the values according to that spinner is changed in edit text boxes. how can i implement this?
Take two array List for spinner1 and 2 default put the values in array List 1 and array List 2 and set the array Adapter to spinner1 and spinner2 using these array List now on selection of Array List 1 change the Array List 2 and update the value in edit text
Edit
I think this is not possible as it will behave like a recursion.
Explanation
Let assume you have two spinners, Spinner1 and Spinner2. You want to select the spinner2 item based on selection of the Spinner1. Till this is it fine and you can change the value of the Spinner2 as you have not implemented the OnItemSelectedListener
of the Spinner2.
Now you want to select Spinner1 item based on the Spinner1 item. If you will try to select Spinner1 item based on the selection of the Spinner2 item then the OnItemSelectedListener
of the Spinner1 will be called because you are trying to select the item. not only this but you have implement the OnItemnSelected
listener of the Spinner1 and you are setting the item in the Spinner2 so the OnItemSelected listener will be work as a Recursion and you will get some Exception or your UI will be blocked.
精彩评论