title: Saving and restoring view state android
body: <p>I'm aware of activity state saving and restoring. 
  But what I want to do is saving and restoring the state of a view.
  I have a custom view and two overrided methods in it:</p>
  
  <pre><code>@Override
  protected void onRestoreInstanceState(Parcelable state) {
      if (state instanceof Bundle) {
          Bundle bundle = (Bundle) state;
          currentLeftX = bundle.getInt(CURRENT_LEFT_X_PARAM, 0);
          currentTopY = bundle.getInt(CURRENT_TOP_Y_PARAM, 0);
      }
      super.onRestoreInstanceState(state);
  }
  
  @Override
  protected Parcelable onSaveInstanceState() {
      super.onSaveInstanceState();
      Bundle bundle = new Bundle();
      bundle.putInt(CURRENT_LEFT_X_PARAM, currentLeftX);
      bundle.putInt(CURRENT_TOP_Y_PARAM, currentTopY);
      return bundle;
  }
  </code></pre>
  
  <p>I expected this to work seamless, but encountered and error:</p>
  
  <blockquote>
    <p>Caused by:
    java.lang.IllegalArgumentException:
    Wrong state class, expecting View
    State but received class
    android.os.Bundle instead. This
    usually happens when two views of
    different type have the same id in the
    same hierarchy. This view's id is
    id/mapViewId. Make sure other views do
    not use the same id.
            at android.view.View.onRestoreInstanceState(View.java:6161)</p>
  </blockquote>
  
  <p>But this view is the only one in my activity. So, I'm asking: </p>
  
  <p>What is the right way to save the state of the view?</p>