title: How to implement QuickReturnList in an Activity?
body: <p>How to implement tabs, using activity for each tab. I found <a href="https://github.com/LarsWerkman/QuickReturnListView" rel="nofollow">this tutorial</a> but it implemented with Fragments. <a href="http://www.androidviews.net/2012/12/quickreturn-listview/" rel="nofollow">Here</a> is a video that show exactly what I want to do.</p>
  
  <p>Here what I been trying to do:</p>
  
  <p><strong>DefaultActivity.java</strong></p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          LayoutInflater inflater  = (LayoutInflater) DefaultActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          view = inflater.inflate(R.layout.fragment, null);
          mHeader = inflater.inflate(R.layout.header, null);
          mQuickReturnView = (TextView) view.findViewById(R.id.sticky);
          mPlaceHolder = mHeader.findViewById(R.id.placeholder);
  
  
  
          mListView = (QuickReturnListView) getListView(); //showing class cast exception here
  
          mQuickReturnView.setText("Default");
          mListView.addHeaderView(mHeader);
  
          String[] array = new String[] { "Android", "Android", "Android",
                  "Android", "Android", "Android", "Android", "Android",
                  "Android", "Android", "Android", "Android", "Android",
                  "Android", "Android", "Android" };
  
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
                  android.R.layout.simple_list_item_1,array);
  
  
          mListView.getViewTreeObserver().addOnGlobalLayoutListener(
                  new ViewTreeObserver.OnGlobalLayoutListener() {
                      @Override
                      public void onGlobalLayout() {
                          mQuickReturnHeight = mQuickReturnView.getHeight();
                          mListView.computeScrollY();
                          mCachedVerticalScrollRange = mListView.getListHeight();
                      }
                  });
  
          mListView.setOnScrollListener(new OnScrollListener() {
              @SuppressLint("NewApi")
              @Override
              public void onScroll(AbsListView view, int firstVisibleItem,
                      int visibleItemCount, int totalItemCount) {
  
                  mScrollY = 0;
                  int translationY = 0;
  
                  if (mListView.scrollYIsComputed()) {
                      mScrollY = mListView.getComputedScrollY();
                  }
  
                  int rawY = mPlaceHolder.getTop()
                          - Math.min(
                                  mCachedVerticalScrollRange
                                          - mListView.getHeight(), mScrollY);
  
                  switch (mState) {
                  case STATE_OFFSCREEN:
                      if (rawY &lt;= mMinRawY) {
                          mMinRawY = rawY;
                      } else {
                          mState = STATE_RETURNING;
                      }
                      translationY = rawY;
                      break;
  
                  case STATE_ONSCREEN:
                      if (rawY &lt; -mQuickReturnHeight) {
                          mState = STATE_OFFSCREEN;
                          mMinRawY = rawY;
                      }
                      translationY = rawY;
                      break;
  
                  case STATE_RETURNING:
                      translationY = (rawY - mMinRawY) - mQuickReturnHeight;
                      if (translationY &gt; 0) {
                          translationY = 0;
                          mMinRawY = rawY - mQuickReturnHeight;
                      }
  
                      if (rawY &gt; 0) {
                          mState = STATE_ONSCREEN;
                          translationY = rawY;
                      }
  
                      if (translationY &lt; -mQuickReturnHeight) {
                          mState = STATE_OFFSCREEN;
                          mMinRawY = rawY;
                      }
                      break;
                  }
  
                  /** this can be used if the build is below honeycomb **/
                  if (Build.VERSION.SDK_INT &lt;= Build.VERSION_CODES.HONEYCOMB) {
                      anim = new TranslateAnimation(0, 0, translationY,
                              translationY);
                      anim.setFillAfter(true);
                      anim.setDuration(0);
                      mQuickReturnView.startAnimation(anim);
                  } else {
                      mQuickReturnView.setTranslationY(translationY);
                  }
  
              }
  
              @Override
              public void onScrollStateChanged(AbsListView view, int scrollState) {
              }
          });
          rlMain = (RelativeLayout)findViewById(R.id.main);
          rlMain.addView(view);
          setContentView(R.layout.activity_main);
  
      }
  </code></pre>
  
  <p>Now it showing error in <code>mListView = (QuickReturnListView) getListView();</code></p>
  
  <pre><code>02-13 21:23:03.389: E/AndroidRuntime(26896): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.quickreturnlistwithactivity/com.example.quickreturnlistwithactivity.QuickReturnActivity}: java.lang.ClassCastException: android.widget.ListView cannot be cast to com.example.quickreturnlistwithactivity.QuickReturnListView
  02-13 21:23:03.389: E/AndroidRuntime(26896): Caused by: java.lang.ClassCastException: android.widget.ListView cannot be cast to com.example.quickreturnlistwithactivity.QuickReturnListView
  02-13 21:23:03.389: E/AndroidRuntime(26896):    at com.example.quickreturnlistwithactivity.QuickReturnActivity.onCreate(QuickReturnActivity.java:67)
  </code></pre>