Java tutorial
//package com.java2s; import android.support.v4.view.ViewPager; import android.view.MenuItem; public class Main { public static void removeCurItem(MenuItem item, int idx, ViewPager vp) { for (int i = 0; i < vp.getAdapter().getCount(); i++) { if (item.getItemId() == idx + i + 1) { vp.setCurrentItem(i); } } } }