title: How to save/Restore state of Views of fragment on Tab change
body: <p>I am following <a href="http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/" rel="nofollow">this</a> tutorial. 
  there are 3 tabs in my App. in tab3 I m making changes to some views (like buttons and EditText spinners etc) and on the behalf of these changes i have to perform some actions in tab2. Simply you can say that i Change some values in tab3 and effect takes places in tab2. I know how to do this. I just want that my values of view becomes resets every time to default values when switching between the <code>tab2</code> and <code>tab3</code></p>
  
  <ul>
  <li>My question is that how can i save the states of my views. so that on resuming the tabs i must get the default look of my views as i had left previously. </li>
  </ul>
  
  <p>One thing more i tell you that i m doing all the work in onCreateView() methos. is this correct way. like this. </p>
  
  <pre><code> public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
  
  Toast.makeText(getActivity(), "onCreateView", Toast.LENGTH_SHORT)
          .show();
  
  if (container == null) {
  
      return null;
  }
  
  View vi = inflater.inflate(R.layout.settings, container, false);
  
  btnInsert = (Button) vi.findViewById(R.id.btnInsert);
  btnInsert.setOnClickListener(this);
  btnPosition = (Button) vi.findViewById(R.id.btnPosition);
  btnPosition.setOnClickListener(this);
  txtPosition = (TextView) vi.findViewById(R.id.txtPosition);
  txtLogo = (TextView) vi.findViewById(R.id.txtLogo);
  imgLogoPreview = (ImageView) vi.findViewById(R.id.imgLogoPreview);
  imgLogoPreview.setOnClickListener(this);
  edTxtUserText = (EditText) vi.findViewById(R.id.edTxtPreview);
  relLogo = (RelativeLayout) vi.findViewById(R.id.RelLogo);
  relText = (RelativeLayout) vi.findViewById(R.id.RelText);
  
  logoWheel = (WheelView) vi.findViewById(R.id.wheelLogo);
  
  logoWheel.setAdapter(new ArrayWheelAdapter&lt;String&gt;(logoWheelList));
  logoWheel.setVisibleItems(4);
  logoWheel.setCurrentItem(1);
  positionWheel = (WheelView) vi.findViewById(R.id.wheelPosition);
  positionWheel.setAdapter(new ArrayWheelAdapter&lt;String&gt;(
          positionWheelTextList));
  
  // LogoWheel changed listener
  changedListenerLogo = new OnWheelChangedListener() {
      public void onChanged(WheelView wheel, int oldValue, int newValue) {
          if (!wheelScrolled) {
  
          }
      }
  };
  
  logoWheel.addChangingListener(changedListenerLogo);
  
  // Wheel scrolled listener
  scrolledListenerLogo = new OnWheelScrollListener() {
  
      public void onScrollStarts(WheelView wheel) {
          wheelScrolled = true;
  
      }
  
      public void onScrollEnds(WheelView wheel) {
          wheelScrolled = false;
          btnInsert.setText(logoWheelList[wheel.getCurrentItem()] + "");
          wheel.setVisibility(View.INVISIBLE);
          if (wheel.getCurrentItem() == 2) {
  
              txtPosition.setVisibility(View.INVISIBLE);
              btnPosition.setVisibility(View.INVISIBLE);
              relText.setVisibility(View.INVISIBLE);
              relLogo.setVisibility(View.INVISIBLE);
  
          } else if (wheel.getCurrentItem() == 1) {
  
              relText.setVisibility(View.VISIBLE);
              relLogo.setVisibility(View.INVISIBLE);
              txtPosition.setVisibility(View.VISIBLE);
              btnPosition.setVisibility(View.VISIBLE);
              btnPosition.setText("Top");
              positionWheel.setAdapter(new ArrayWheelAdapter&lt;String&gt;(
                      positionWheelTextList));
              positionWheel.setVisibleItems(4);
              positionWheel.setCurrentItem(1);
  
          } else if (wheel.getCurrentItem() == 0) {
  
              relLogo.setVisibility(View.VISIBLE);
              relText.setVisibility(View.INVISIBLE);
              txtPosition.setVisibility(View.VISIBLE);
              btnPosition.setVisibility(View.VISIBLE);
              btnPosition.setText("Top Left");
              positionWheel.setAdapter(new ArrayWheelAdapter&lt;String&gt;(
                      positionWheelLogoList));
              positionWheel.setVisibleItems(4);
              positionWheel.setCurrentItem(1);
  
          }
      }
  };
  
  logoWheel.addScrollingListener(scrolledListenerLogo);
  
  // /////////////////////Positon Wheel Listners///////////
  
  // LogoWheel changed listener
  changedListenerPosition = new OnWheelChangedListener() {
      public void onChanged(WheelView wheel, int oldValue, int newValue) {
          if (!wheelScrolled) {
  
          }
      }
  };
  
  positionWheel.addChangingListener(changedListenerPosition);
  
  // Wheel scrolled listener
  scrolledListenerPosition = new OnWheelScrollListener() {
  
      public void onScrollStarts(WheelView wheel) {
          wheelScrolled = true;
  
      }
  
      public void onScrollEnds(WheelView wheel) {
          wheelScrolled = false;
  
          String btnStatus = btnInsert.getText().toString();
          if (btnStatus.equals("Logo")) {
              btnPosition.setText(positionWheelLogoList[positionWheel
                      .getCurrentItem()] + "");
  
          } else if (btnStatus.equals("Text")) {
              btnPosition.setText(positionWheelTextList[positionWheel
                      .getCurrentItem()] + "");
          }
  
          wheel.setVisibility(View.INVISIBLE);
  
      }
  };
  
  positionWheel.addScrollingListener(scrolledListenerPosition);
  
  return vi;
  </code></pre>
  
  <p>}</p>
  
  <ul>
  <li><p>at what point i must save the states and at what point i should retrieve the savedstates?</p></li>
  <li><p>Please tell me the how to implement the lifecycle of fragment in simple words.</p></li>
  </ul>
  
  <p>i also tried the <code>saveInstance()</code> method of fragment. but not called.</p>
  
  <p>Thanks</p>