我想做像facebook这样的事情,当我们拖动滚动视图直到负y时,活动指示器将显示并刷新视图。
当我实现以下代码时,它正在使用IOS。但是,在Android设备上运行时,滚动y似乎只能有0或大于0的值,并且无法滚动滚动到负区域。
root@pandora:~# LANG=C apt-get install phpapi-20100525
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package phpapi-20100525 is a virtual package provided by:
php5-fpm 5.4.45-0+deb7u2 [Not candidate version]
php5-cli 5.4.45-0+deb7u2 [Not candidate version]
php5-cgi 5.4.45-0+deb7u2 [Not candidate version]
libphp5-embed 5.4.45-0+deb7u2 [Not candidate version]
libapache2-mod-php5filter 5.4.45-0+deb7u2 [Not candidate version]
libapache2-mod-php5 5.4.45-0+deb7u2 [Not candidate version]
E: Package 'phpapi-20100525' has no installation candidate
root@pandora:~#
如何让它在Android上运行?
答案 0 :(得分:2)
我猜你想要一个Xamarin.Forms解决方案,即使你没有在你的问题中提到过,因为Xamarin.Forms标签。您无需手动编码。 James Montemagno为我们完成了所有艰苦的工作。这是PullToRefreshLayout github页面的链接。您只需要在Xaml中的ScrollView位置添加PullToRefreshLayout,并将ScrollView设置为它的内容。
编辑:按照@cheesebaron的建议解释用法。
您可以安装插件Nuget包Refractored.XamForms.PullToRefresh。
然后我们可以通过添加 PullToRefreshLayout 作为ScrollView的父级来实现PullToRefresh操作。我引用了Github页面中给出的例子
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="RefreshSample.Views.ScrollViewXamlPage"
xmlns:controls="clr-namespace:Refractored.XamForms.PullToRefresh;assembly=Refractored.XamForms.PullToRefresh"
Title="Xaml Scroll">
<controls:PullToRefreshLayout
IsPullToRefreshEnabled="True"
RefreshCommand="{Binding RefreshCommand}"
IsRefreshing="{Binding IsBusy}"
RefreshColor="Blue">
<ScrollView
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<StackLayout
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue"/>
<BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Red"/>
<BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Yellow"/>
<BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Purple"/>
<BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Maroon"/>
<BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue"/>
<BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Red"/>
<BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Yellow"/>
<BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Purple"/>
<BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Maroon"/>
</StackLayout>
</ScrollView>
</controls:PullToRefreshLayout>
</ContentPage>