结果:
1.网络好的情况下,打开很快,很流畅。
2.地址栏真心不好使,如果真要做应用,这块必须自己优化一下。
实例代码:
1 unit Unit1; 2 3 interface 4 5 uses 6 System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, 7 FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, 8 FMX.Edit, FMX.Controls.Presentation, FMX.WebBrowser; 9 10 type 11 TForm1 = class(TForm) 12 WebBrowser1: TWebBrowser; 13 ToolBar1: TToolBar; 14 Edit1: TEdit; 15 Button1: TButton; 16 Button2: TButton; 17 Button3: TButton; 18 StatusBar1: TStatusBar; 19 procedure Button1Click(Sender: TObject); 20 procedure Edit1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; 21 Shift: TShiftState); 22 procedure Button2Click(Sender: TObject); 23 procedure Button3Click(Sender: TObject); 24 private 25 { Private declarations } 26 public 27 { Public declarations } 28 end; 29 30 var 31 Form1: TForm1; 32 33 implementation 34 35 {$R *.fmx} 36 {$R *.NmXhdpiPh.fmx ANDROID} 37 38 //打开网页 39 procedure TForm1.Button1Click(Sender: TObject); 40 begin 41 WebBrowser1.URL := Edit1.Text; 42 end; 43 44 //返回 45 procedure TForm1.Button2Click(Sender: TObject); 46 begin 47 WebBrowser1.GoBack; 48 end; 49 50 //前进 51 procedure TForm1.Button3Click(Sender: TObject); 52 begin 53 WebBrowser1.GoForward; 54 end; 55 56 procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; 57 Shift: TShiftState); 58 begin 59 if Key = vkReturn then 60 begin 61 //当按下按钮时,隐藏输入键盘并把焦点移动到 btnGO 上。 62 WebBrowser1.URL := edit1.Text; 63 Button1.SetFocus; 64 end; 65 end; 66 67 end.
时间: 2024-11-05 10:06:51