標籤:
結果:
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 type11 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 private25 { Private declarations }26 public27 { Public declarations }28 end;29 30 var31 Form1: TForm1;32 33 implementation34 35 {$R *.fmx}36 {$R *.NmXhdpiPh.fmx ANDROID}37 38 //開啟網頁39 procedure TForm1.Button1Click(Sender: TObject);40 begin41 WebBrowser1.URL := Edit1.Text;42 end;43 44 //返回45 procedure TForm1.Button2Click(Sender: TObject);46 begin47 WebBrowser1.GoBack;48 end;49 50 //前進51 procedure TForm1.Button3Click(Sender: TObject);52 begin53 WebBrowser1.GoForward;54 end;55 56 procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char;57 Shift: TShiftState);58 begin59 if Key = vkReturn then60 begin61 //當按下按鈕時,隱藏輸入鍵盤並把焦點移動到 btnGO 上。62 WebBrowser1.URL := edit1.Text;63 Button1.SetFocus;64 end;65 end;66 67 end.
Android執行個體-利用WebBrowser實現瀏覽器(XE8+小米2)