//------------------------------------------------------------------------------
// 2013.12.30 by 龟山阿卍 QQ 1467948783 -
// http://www.cnblogs.com/onechen/ -
// -
// 需修改 -
// FMX.Platform.Android.pas -
// function TPlatformAndroid.GetScrollingBehaviour: TScrollingBehaviours; -
//------------------------------------------------------------------------------
unit Main;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.ListView.Types, FMX.Objects, FMX.ListView, FMX.Ani;
type
TForm1 = class(TForm)
ToolBar1: TToolBar;
ListView1: TListView;
PullPaintBox: TPaintBox;
AniIndicator1: TAniIndicator;
RefreshTimer: TTimer;
RefreshLabel: TLabel;
RefreshImage: TImage;
FloatAnimation1: TFloatAnimation;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure ListView1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Single);
procedure ListView1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
procedure RefreshTimerTimer(Sender: TObject);
private
ShowUp, ShowDown: Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
Item1: TListViewItem;
begin
for i:=0 to 100 do
begin
Item1 := ListView1.Items.Add;
Item1.Text := i.ToString;
end;
ShowUp := False;
ShowDown := False;
end;
procedure TForm1.ListView1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Single);
begin
if not AniIndicator1.Visible then
begin
RefreshLabel.Visible := True;
if ListView1.ScrollViewPos < -80 then
begin
RefreshLabel.Text := '放开后可更新';
RefreshImage.Visible := True;
if not ShowUp then
begin
ShowUp := True;
FloatAnimation1.StartValue := 360;
FloatAnimation1.StopValue := 180;
FloatAnimation1.Start;
end;
end
else
if ListView1.ScrollViewPos < -40 then
begin
RefreshLabel.Text := '下拉可更新';
RefreshImage.Visible := True;
if not ShowDown then
begin
ShowDown := True;
FloatAnimation1.StartValue := 180;
FloatAnimation1.StopValue := 360;
FloatAnimation1.Start;
end;
end
else
begin
RefreshLabel.Text := '';
RefreshImage.Visible := False;
end;
end;
end;
procedure TForm1.ListView1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
if RefreshLabel.Visible then
begin
RefreshLabel.Visible := False;
// 开始更新
AniIndicator1.Visible := True;
AniIndicator1.Enabled := True;
RefreshTimer.Enabled := True;
end;
end;
procedure TForm1.RefreshTimerTimer(Sender: TObject);
begin
// 结束更新
RefreshTimer.Enabled := False;
AniIndicator1.Enabled := False;
AniIndicator1.Visible := False;
ShowUp := False;
ShowDown := False;
end;
end.