For example, I have a fragment that contains two seekbar, one loaded of the layout XML and another loaded in runtime.
public class FragmentEqualizer extends Fragment {
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
setRetainInstance(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle b)
{
View view = inflater.inflate(R.layout.fragment_equalizer, container, false);
myLinearLayout = (LinearLayout) view.findByViewId(R.id.linearLayout);
SeekBar bar = new SeekBar(view.get.Context());
bar.setLayoutParams(layoutParams);
bar.setMax(100);
bar.setProgress(50);
myLinearLayout.addview(bar);
return view;
}
}
When i start the application and change the progress bar of each seekbar and after I changed the screen orientation of my device, the state of progress bar of view loaded keeps equal while the state of progress bar of wiew loaded in runtime get default like if i don't have changed.
My problem is seemed with this setRetainInstance not retaining the instance
Can somebody help me???
tks