how to disable ViewPager swiping using android-support-v4.jar in android

I'm creating a android application with target on 2.2. I still want to use the ViewPager provided in the want need to disable Viewpager swipping on button click.i have use following code for disable. but its don't work.

public class ServiesDeail extends FragmentActivity{

    ServiesTitleFragmentAdapter mAdapter;
    ViewPager mPager;
        int position = 0 ;

    @SuppressWarnings({ "rawtypes", "unchecked" })
    protected void onCreate(Bundle savedInstanceState) {

        LinearLayout lnrparent = (LinearLayout) findViewById(;
        LayoutInflater inflater = (LayoutInflater)                                                         this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.menu_deatil, null);

        mAdapter = new ServiesTitleFragmentAdapter(getSupportFragmentManager());

        mPager = (ViewPager) findViewById(;

        TitlePageIndicator indicator = (TitlePageIndicator) findViewById(;

            Menu_Button.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

if u have any idea anyone.. please give me reponse.. i m waiting your response


You will have to extend the view pager and create a custom view pager for you which can be used in the xml instead of the view pager that you get from support library and change some properties, see the code below, it worked for me. Use the customviewpager in your code, and the swiping will be disabled.

public class CustomViewPager extends ViewPager{

    public CustomViewPager(Context context){

    public CustomViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);

    public boolean onInterceptTouchEvent(MotionEvent ev){
        return false;

    public boolean onTouchEvent(MotionEvent ev){
        return false;

Need Your Help

Calling a Variable from another Class

c# class variables static

How can I access a variable in one public class from another public class in C#?

IList<T> to ObservableCollection<T>

c# silverlight

I have a method in a Silverlight app that currently returns an IList and I would like to find the cleanest way to turn this into an ObservableCollection so: