Reputation: 801
I am stuck at a point where I need to hide the list view if the state of view pager is changed. i.e if I swipe from fragment 1 to fragment two in a view pager the I want my list view to hide. That might be achieved by OnPageScrollStateChanged by I dont know the implementation on xamarin studio.
Upvotes: 3
Views: 2208
Reputation: 387
For records : Here is how the events are popped.
OnPageScrollStateChanged state = 2 (SCROLL_STATE_SETTLING)==> start scrolling
onPageSelected ==> a page has been selected (before start scrolling to it), check pos.
onPageScrolled ==> called many times while scrolling (~50% for old pos, ~50% for new pos)
OnPageScrollStateChanged state = 0 (SCROLL_STATE_IDLE)==> on end scroll (settled)
For any one who came across!
Upvotes: 0
Reputation: 801
Following could be the approach for the ques
public class HomePageActivity : FragmentActivity, Android.Support.V4.View.ViewPager.IOnPageChangeListener
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Create your application here
SetContentView(Resource.Layout.home);
var viewPager_up = FindViewById<Android.Support.V4.View.ViewPager>(Resource.Id.viewPager_up);
viewPager_up.AddOnPageChangeListener (this);
}
public void OnPageScrollStateChanged (int state)
{
Console.WriteLine ("OnPageScrollStateChanged "+" "+state);
}
public void OnPageScrolled (int position, float positionOffset, int positionOffsetPixels){
Console.WriteLine ("OnPageScrolled "+" "+position);
}
public void OnPageSelected (int position)
{
Console.WriteLine ("OnPageSelected"+" "+position);
}
}
Upvotes: 10