注意:XE7 已提供下拉更的功能。

说明:展示如何在 Android 平台下,使用 ListView 下拉更新。

适用:Delphi XE5 , XE6

修改:需要修改到 Delphi 源码 FMX.Platform.Android.pas,请见:[原创] 让 ListView 在 Android 可回弹

视频:http://v.youku.com/v_show/id_XNjU1MzExMDY0.html

源码下载:[原创]ListView下拉更新_XE5.zip

源码下载:[原创]ListView下拉更新_XE6.zip

ListView 下拉更新 (支持 Android)-LMLPHP
//------------------------------------------------------------------------------
// 2013.12. by 龟山阿卍 QQ -
// 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:= to 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 < - then
begin
RefreshLabel.Text := '放开后可更新'; RefreshImage.Visible := True;
if not ShowUp then
begin
ShowUp := True;
FloatAnimation1.StartValue := ;
FloatAnimation1.StopValue := ;
FloatAnimation1.Start;
end;
end
else
if ListView1.ScrollViewPos < - then
begin
RefreshLabel.Text := '下拉可更新'; RefreshImage.Visible := True;
if not ShowDown then
begin
ShowDown := True;
FloatAnimation1.StartValue := ;
FloatAnimation1.StopValue := ;
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.
05-04 12:16