public void scrollToTop() {
   if (listView != null) {
     int top = listView.getRefreshableView().getFirstVisiblePosition();
     int bottom = listView.getRefreshableView().getLastVisiblePosition();
     if (top >= (bottom - top)) {
       listView.getRefreshableView().setSelection(bottom - top);
       listView.getRefreshableView().smoothScrollToPosition(0);
     } else {
       listView.getRefreshableView().smoothScrollToPosition(0);
     }
   }
 }
  private void findViews() {
    View ctCountView = View.inflate(getView().getContext(), R.layout.nim_contacts_count_item, null);
    countView = (TextView) ctCountView.findViewById(R.id.contactCountText);
    loadingFrame = findView(R.id.contact_loading_frame);
    initAdapter();
    listView = findView(R.id.contact_list_view);
    ctCountView.setClickable(false);
    listView.getRefreshableView().addFooterView(ctCountView);
    listView.setAdapter(adapter);
    listView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(), true, true));

    ContactItemClickListener listener = new ContactItemClickListener();
    listView.setOnItemClickListener(listener);
    listView.setOnItemLongClickListener(listener);
  }
  private void initPullToRefreshListView() {
    listView.setOnRefreshListener(
        new PullToRefreshBase.OnRefreshListener2<ListView>() {
          @Override
          public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
            requestUserData();
          }

          @Override
          public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {}
        });
  }