@Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_left) {
      mListView.setSwipeDirection(SwipeMenuListView.DIRECTION_LEFT);
      return true;
    }
    if (id == R.id.action_right) {
      mListView.setSwipeDirection(SwipeMenuListView.DIRECTION_RIGHT);
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_bookmark, container, false);

    // Set the adapter
    mListView = (SwipeMenuListView) view.findViewById(android.R.id.list);
    mListView.setAdapter(mAdapter);
    mListView.setMenuCreator(creator);
    // Set OnItemClickListener so we can be notified on item clicks
    mListView.setOnItemClickListener(this);
    mListView.setOnScrollListener(
        new AbsListView.OnScrollListener() {
          int mLastFirstVisibleItem = 0;

          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {}

          @Override
          public void onScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (view.getId() == mListView.getId()) {
              final int currentFirstVisibleItem = mListView.getFirstVisiblePosition();

              if (currentFirstVisibleItem > mLastFirstVisibleItem) {
                // getSherlockActivity().getSupportActionBar().hide();
                ((ActionBarActivity) getActivity()).getSupportActionBar().hide();
              } else if (currentFirstVisibleItem < mLastFirstVisibleItem) {
                // getSherlockActivity().getSupportActionBar().show();
                ((ActionBarActivity) getActivity()).getSupportActionBar().show();
              }
              mLastFirstVisibleItem = currentFirstVisibleItem;
            }
          }
        });
    mListView.setOnMenuItemClickListener(
        new SwipeMenuListView.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
            switch (index) {
              case 0:
                // delete
                DB.delOne(data.get(position));
                // Update Home screen product list.
                MyApp.getInstance().updateProductFromWishlist(false, data.get(position).objectId);
                // Update wishlist view
                data = DB.getAllProduct();
                mAdapter = new FavoriteAdapter(getActivity(), data);
                mListView.setAdapter(mAdapter);
                break;
            }
            // false : close the menu; true : not close the menu
            return false;
          }
        });
    mListView.setSwipeDirection(SwipeMenuListView.DIRECTION_LEFT);
    return view;
  }