Delphi专题 ·

delphi安卓动态切换本地主题

主要代码

procedure TForm1.btn1Click(Sender: TObject);
begin
	Toast('Toast信息', LongToast);
end;


procedure TForm1.btn2Click(Sender: TObject);
begin
  ShowMessage('Atom Developer');
end;

procedure TForm1.btn4Click(Sender: TObject);
begin
  MessageDlg('你真的想关闭Delphi开发的应用程序吗?',
    System.UITypes.TMsgDlgType.mtInformation,
    [System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo], 0,
    procedure(const BotaoPressionado: TModalResult)
      begin
        case BotaoPressionado of
          mrYes: begin
              Toast('你选择了 是', ShortToast);
            end;
          mrNo: begin
              Toast('你选择了 否', ShortToast);
            end;
        end;
      end
    );
end;

procedure TForm1.cmb1Change(Sender: TObject);
begin
  TJAndroidThemeHelper.ThemeID := cmb1.ListItems[cmb1.ItemIndex].Tag;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  aItem: TListBoxItem;
begin
  aItem := TListBoxItem.Create(cmb1);
  aItem.Tag := TJAlertDialog.JavaClass.THEME_TRADITIONAL;
  aItem.Text := 'THEME_TRADITIONAL';
  cmb1.AddObject(aItem);

  aItem := TListBoxItem.Create(cmb1);
  aItem.Tag := TJAlertDialog.JavaClass.THEME_DEVICE_DEFAULT_DARK;
  aItem.Text := 'THEME_DEVICE_DEFAULT_DARK';
  cmb1.AddObject(aItem);

  aItem := TListBoxItem.Create(cmb1);
  aItem.Tag := TJAlertDialog.JavaClass.THEME_DEVICE_DEFAULT_LIGHT;
  aItem.Text := 'THEME_DEVICE_DEFAULT_LIGHT';
  cmb1.AddObject(aItem);

  aItem := TListBoxItem.Create(cmb1);
  aItem.Tag := TJAlertDialog.JavaClass.THEME_HOLO_DARK;
  aItem.Text := 'THEME_HOLO_DARK';
  cmb1.AddObject(aItem);

  aItem := TListBoxItem.Create(cmb1);
  aItem.Tag := TJAlertDialog.JavaClass.THEME_HOLO_LIGHT;
  aItem.Text := 'THEME_HOLO_LIGHT';
  cmb1.AddObject(aItem);
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  RebuildOrientation;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  TmyWindow.StatusBarColor(Self, TAlphaColor($FF2196E0));
end;

procedure TForm1.RebuildOrientation;
begin
  Content.Margins.Top := TmyWindow.StatusBarHeight;
end;

initialization

  TmyWindow.Init;

end.

相关下载

点击下载

参与评论