خرید بک لینک

Vote count: 0

I have 5 fragments and I want to swipe between them back and forward with buttons, I actually made a class to stop swiping with just touching, but I couldn't reach a good sulotion to make a swipe between two fragments with a button, so maybe can someone help me please.

This is the fragment adapter in the main activity:

public class AFragmentAdapter : FragmentPagerAdapter
    {

        public AFragmentAdapter(Android.Support.V4.App.FragmentManager fm) : base(fm)
        {

        }

        public override int Count
        {
            get
            {
                retu 5;
            }
        }

        public override Android.Support.V4.App.Fragment GetItem(int position)
        {
            switch (position)
            {            
                case 0: retu new AFragment();
                case 1: retu new BFragment();
                case 2: retu new CFragment();
                case 3: retu new DFragment();
                case 4: retu new EFragment();
                default: retu new AFragment();
            }

        }

    }

And this is my fragment activity so far:

public class a : FragmentActivity
    {

        private Button nxt1;
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.a);

            nxt1 = FindViewById<Button>(Resource.Id.but1);
            nxt1.Click += Nxt1_Click;
        }

        private void Nxt1_Click(object sender, EventArgs e)
        {

        }

    }

And this is my Class to stop swiping with touches:

 public class NonSwipeableViewPager : ViewPager
    {

        private new bool Enabled;

        public NonSwipeableViewPager(IntPtr handle, JniHandleOwnership transfer)
            : base(handle, transfer)
        {

        }

        public NonSwipeableViewPager(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            this.Enabled = true;
        }


        public override bool OnTouchEvent(MotionEvent e)
        {
            if (this.Enabled)
            {
                retu base.OnTouchEvent(e);
            }
            retu false;
        }

        public override bool OnInterceptTouchEvent(MotionEvent ev)
        {
            if (this.Enabled)
            {
                retu base.OnInterceptTouchEvent(ev);
            }
            retu false;
        }

        public void SetPagingEnabled(bool enabled)
        {
            this.Enabled = enabled;
        }
    }

Thanks :)

asked 12 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 15 خرداد 1395 ساعت: 17:35

صفحه بندی