Esempio n. 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            /**
             * Get ListView and give it an adapter to display the sample items
             */
            ListView     listView = this.ListView;
            IListAdapter adapter  = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1,
                                                     ITEMS);

            listView.Adapter = adapter;

            /**
             * Here we create a PullToRefreshAttacher manually without an Options instance.
             * PullToRefreshAttacher will manually create one using default values.
             */
            mPullToRefreshAttacher = new PullToRefreshAttacher(this, ListView);

            // Set Listener to know when a refresh should be started
            mPullToRefreshAttacher.Refresh += delegate {
                Task.Factory.StartNew(() => { Thread.Sleep(5000); })
                .ContinueWith(task => { mPullToRefreshAttacher.SetRefreshComplete(); });
            };
        }
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView (Resource.Layout.activity_scrollview);

			// Retrieve PullToRefreshAttacher from PullToRefreshLayout
			mPullToRefreshAttacher = PullToRefreshLayout.GetAttacher (this, Resource.Id.ptr_layout);

			// Set Listener to know when a refresh should be started
			mPullToRefreshAttacher.Refresh += delegate {
				Task.Factory.StartNew(()=> { Thread.Sleep (5000); })
				.ContinueWith(task => { mPullToRefreshAttacher.SetRefreshComplete(); });
			};
		}
Esempio n. 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_scrollview);

            // Retrieve PullToRefreshAttacher from PullToRefreshLayout
            mPullToRefreshAttacher = PullToRefreshLayout.GetAttacher(this, Resource.Id.ptr_layout);

            // Set Listener to know when a refresh should be started
            mPullToRefreshAttacher.Refresh += delegate {
                Task.Factory.StartNew(() => { Thread.Sleep(5000); })
                .ContinueWith(task => { mPullToRefreshAttacher.SetRefreshComplete(); });
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_gridview);

            GridView     gridView = FindViewById <GridView> (Resource.Id.ptr_gridview);
            IListAdapter adapter  = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, ITEMS);

            gridView.Adapter = adapter;

            // As we're modifying some of the options, create an instance of
            // PullToRefreshAttacher.Options
            PullToRefreshAttacher.Options ptrOptions = new PullToRefreshAttacher.Options();

            // Here we make the refresh scroll distance to 75% of the GridView height
            ptrOptions.RefreshScrollDistance = 0.75f;

            /**
             * As GridView is an AbsListView derived class, we create a new AbsListViewDelegate
             * instance. You do NOT need to do this if you're using a supported scrollable Views. It is
             * merely in this sample to show you how to set a custom delegate.
             */
            ptrOptions.DelegateField = new AbsListViewDelegate();

            // Here we customise the animations which are used when showing/hiding the header view
            ptrOptions.HeaderInAnimation  = Resource.Animation.slide_in_top;
            ptrOptions.HeaderOutAnimation = Resource.Animation.slide_out_top;

            // Here we define a custom header layout which will be inflated and used
            ptrOptions.HeaderLayout = Resource.Layout.customised_header;

            // Here we define a custom header transformer which will alter the header based on the
            // current pull-to-refresh state
            ptrOptions.HeaderTransformer = new CustomisedHeaderTransformer();

            // Here we create a PullToRefreshAttacher manually with the Options instance created above.
            mPullToRefreshAttacher = new PullToRefreshAttacher(this, gridView, ptrOptions);

            // Set Listener to know when a refresh should be started
            mPullToRefreshAttacher.Refresh += delegate {
                Task.Factory.StartNew(() => { Thread.Sleep(5000); })
                .ContinueWith(task => { mPullToRefreshAttacher.SetRefreshComplete(); });
            };
        }
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);

			/**
         * Get ListView and give it an adapter to display the sample items
         */
			ListView listView = this.ListView;
			IListAdapter adapter = new ArrayAdapter (this, Android.Resource.Layout.SimpleListItem1,
			                                         ITEMS);
			listView.Adapter = adapter;

			/**
         * Here we create a PullToRefreshAttacher manually without an Options instance.
         * PullToRefreshAttacher will manually create one using default values.
         */
			mPullToRefreshAttacher = new PullToRefreshAttacher (this, ListView);

			// Set Listener to know when a refresh should be started
			mPullToRefreshAttacher.Refresh += delegate {
				Task.Factory.StartNew(()=> { Thread.Sleep (5000); })
					.ContinueWith(task => { mPullToRefreshAttacher.SetRefreshComplete(); });
			};
		}
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView (Resource.Layout.activity_gridview);

			GridView gridView = FindViewById<GridView> (Resource.Id.ptr_gridview);
			IListAdapter adapter = new ArrayAdapter (this, Android.Resource.Layout.SimpleListItem1, ITEMS);
			gridView.Adapter = adapter;

			// As we're modifying some of the options, create an instance of
			// PullToRefreshAttacher.Options
			PullToRefreshAttacher.Options ptrOptions = new PullToRefreshAttacher.Options ();

			// Here we make the refresh scroll distance to 75% of the GridView height
			ptrOptions.RefreshScrollDistance = 0.75f;

			/**
         * As GridView is an AbsListView derived class, we create a new AbsListViewDelegate
         * instance. You do NOT need to do this if you're using a supported scrollable Views. It is
         * merely in this sample to show you how to set a custom delegate.
         */
			ptrOptions.DelegateField = new AbsListViewDelegate ();

			// Here we customise the animations which are used when showing/hiding the header view
			ptrOptions.HeaderInAnimation = Resource.Animation.slide_in_top;
			ptrOptions.HeaderOutAnimation = Resource.Animation.slide_out_top;

			// Here we define a custom header layout which will be inflated and used
			ptrOptions.HeaderLayout = Resource.Layout.customised_header;

			// Here we define a custom header transformer which will alter the header based on the
			// current pull-to-refresh state
			ptrOptions.HeaderTransformer = new CustomisedHeaderTransformer ();

			// Here we create a PullToRefreshAttacher manually with the Options instance created above.
			mPullToRefreshAttacher = new PullToRefreshAttacher (this, gridView, ptrOptions);

			// Set Listener to know when a refresh should be started
			mPullToRefreshAttacher.Refresh += delegate {
				Task.Factory.StartNew(()=> { Thread.Sleep (5000); })
					.ContinueWith(task => { mPullToRefreshAttacher.SetRefreshComplete(); });
			};
		}