@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle("WOW");

    view = new CustomView(getApplicationContext(), actionBar);
    setContentView(view);
    view.setRefreshListner(SampleForGmailLikePullToRefresh.this);
    view.setActionBar(SampleForGmailLikePullToRefresh.this);
    mListView = view.getListView();

    list = new ArrayList<Integer>();
    adapter = new DummyAdapter(SampleForGmailLikePullToRefresh.this, 0, list);

    LayoutInflater layoutInflater =
        (LayoutInflater)
            SampleForGmailLikePullToRefresh.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View loadingView = layoutInflater.inflate(R.layout.view_listview_loading, null);
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    params.setMargins(0, 5, 0, 0);
    loadingView.setLayoutParams(params);
    mListView.setEmptyView(null);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case R.id.show_loading:
        view.startLoading();
        return true;

      case R.id.stop_loading:
        view.stopLoading();
        return true;

      case R.id.add_data_refresh:
        addTempDummyData();
        return true;

      default:
        return super.onOptionsItemSelected(item);
    }
  }
  public void addTempDummyData() {

    view.startLoading();

    for (int i = 0; i < 10; i++) {
      adapter.add(i, i);
      adapter.notifyDataSetChanged();
    }

    handler.postDelayed(runnable, 5000);
  }
 @Override
 public void run() {
   mListView.invalidate();
   mListView.requestLayout();
   view.stopLoading();
 }