0
I have 3 Spinners inside a Fragment, the problem I’m having is when I rotate the Tablet screen and the screen rebuilds, so the Spinners are zeroed.
The first Spinner comes from the bank, depending on the selection of the first Spinner the second is filled and so does the third Spinner when I choose the second.
I already handle the data, because when selecting the item it already saved in the database, however, when rotating the screen I have the problems described above, follows a method that I use to show the saved item even leaving the screen...
public void setSpinnerSelection(Spinner spinner, Adapter adapter, String text) {
for (int i = 0; i < adapter.getCount(); i++) {
String comparar = adapter.getItem(i).toString();
if (comparar.equals(text)) {
spinner.setSelection(i);
}
}
}
I noticed something strange too, is it common when Fragment is rebuilt it performs what is inside that Spinner method? " setOnItemSelectedListener", I realized that this is exactly the "bottleneck".
In short, I wanted to know an intelligent way to work with the life cycle of Fragment.