• Android实例-处理隐藏输入法后不再显示问题(XE8+小米2)


    结果:

    1.可以处理再次显示问题,但缺点是每个控件都要处理一次,累。哪位大神有好的处理方法,请M我。

    实例代码:

     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.ComboEdit,
     8   FMX.Edit, FMX.EditBox, FMX.NumberBox, FMX.DateTimeCtrls, FMX.ScrollBox,
     9   FMX.Memo, FMX.Controls.Presentation, FMX.StdCtrls,
    10   FMX.VirtualKeyboard,//需要引入
    11   FMX.Platform,//需要引入
    12   FMX.Layouts;
    13 
    14 type
    15   TForm1 = class(TForm)
    16     VertScrollBox1: TVertScrollBox;
    17     Layout1: TLayout;
    18     Memo1: TMemo;
    19     Label1: TLabel;
    20     Button1: TButton;
    21     Edit1: TEdit;
    22     Edit2: TEdit;
    23     procedure FormCreate(Sender: TObject);
    24     procedure FormFocusChanged(Sender: TObject);
    25     procedure FormVirtualKeyboardHidden(Sender: TObject;
    26       KeyboardVisible: Boolean; const Bounds: TRect);
    27     procedure FormVirtualKeyboardShown(Sender: TObject;
    28       KeyboardVisible: Boolean; const Bounds: TRect);
    29     procedure Edit2Click(Sender: TObject);
    30   private
    31     //定义输入法变量
    32     FService: IFMXVirtualKeyboardToolbarService;
    33     FService_kb: FMX.VirtualKeyboard.IFMXVirtualKeyboardService;
    34     { Private declarations }
    35   public
    36     { Public declarations }
    37   end;
    38 
    39 var
    40   Form1: TForm1;
    41 
    42 implementation
    43 
    44 {$R *.fmx}
    45 {$R *.NmXhdpiPh.fmx ANDROID}
    46 //如果再次点击EDIT应做出反映
    47 procedure TForm1.Edit2Click(Sender: TObject);
    48 begin
    49   if TEdit(Sender).IsFocused and Assigned(FService_kb) then
    50   try
    51     FService_kb.ShowVirtualKeyboard(TEdit(Sender));
    52   except
    53   end;
    54 end;
    55 
    56 procedure TForm1.FormCreate(Sender: TObject);
    57 begin
    58   //控制虚拟键盘的操作
    59   TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService,
    60   IInterface(FService_kb));
    61   if TPlatformServices.Current.SupportsPlatformService
    62   (IFMXVirtualKeyboardToolbarService, IInterface(FService))then
    63   begin
    64     FService.SetToolbarEnabled(true);
    65     FService.SetHideKeyboardButtonVisibility(true);
    66   end;
    67 end;
    68 
    69 end.
  • 相关阅读:
    Java基础08 继承
    Java基础07 包
    Java基础06 组合
    Java基础05 实施接口
    Java基础04 封装与接口
    Java基础03 构造器与方法重载
    Java基础02 方法与数据成员
    Java基础01 从HelloWorld到面向对象
    151. Reverse Words in a String
    168. Excel Sheet Column Title
  • 原文地址:https://www.cnblogs.com/FKdelphi/p/4781746.html
Copyright © 2020-2023  润新知