![]() |
GUI abhänging vom Target auswählen
Hallo,
da ich jetzt gerade dabei bin, für meine App eine Oberfläche mit der iCL zu basteln, aber ich trotzdem noch Android unterstützen will, ist mir folgendes eingefallen: Im Root-Verzeichnis des Projekts liegen die unteren 2 Schichten (Steuerung und Datenerhaltungschicht). In einem weiteren Verzeichnis GUI befinden sich zwei Ordner namens FMX und iOS. Je nach dem, welche Platform ausgewähl wurde, soll der Compiler sich die richtige Oberfläche suchen. Das sieht im endeffekt so aus:
Delphi-Quellcode:
Ich finde die Idee klasse, nur hapert es noch an der Umsetzung.
program Test;
uses System.StartUpCopy, FMX.Forms, {$IFDEF IOS} U_MainiOS in 'GUI\iOS\U_MainiOS.pas' {F_MainiOS}, {$ENDIF } {$IFDEF ANDROID} U_MainFMX in 'GUI\FMX\U_MainFMX.pas' {F_MainFMX}, {$ENDIF } {$IFDEF MSWINDOWS} U_MainFMX in 'GUI\FMX\U_MainFMX.pas' {F_MainFMX}, {$ENDIF } MyData in 'MyData.pas', MyControl in 'MyControl.pas', Basics in 'Basics.pas'; {$R *.res} begin Application.Initialize; Application.FormFactor.Orientations := [TFormOrientation.soInvertedLandscape]; {$IFDEF IOS} Application.CreateForm(TF_MainiOS, F_MainiOS); {$ENDIF } {$IFDEF ANDROID} Application.CreateForm(TF_MainFMX, F_MainFMX); {$ENDIF } {$IFDEF MSWINDOWS} Application.CreateForm(TF_MainFMX, F_MainFMX); {$ENDIF } Application.Run; end. Unter iOS funtkioniert es, unter Windows und Android läd es keine Obefläche. Weiß jemand, woran das liegt? Viele Grüße Croco EDIT: Hab mich geirrt :oops: . Hab mal alle generierten Dateien gelöscht und schwups hat es funktioniert. |
AW: GUI abhänging vom Target auswählen
Die U_MainFMX wird auch einkompiliert?
Was sagt denn der Debugger? ach ja
Delphi-Quellcode:
[edit]
program Test;
uses System.StartUpCopy, FMX.Forms, {$IFDEF IOS} U_MainiOS in 'GUI\iOS\U_MainiOS.pas' {F_MainiOS}, {$ELSE} U_MainFMX in 'GUI\FMX\U_MainFMX.pas' {F_MainFMX}, {$ENDIF} MyData in 'MyData.pas', MyControl in 'MyControl.pas', Basics in 'Basics.pas'; {$R *.res} begin Application.Initialize; Application.FormFactor.Orientations := [TFormOrientation.soInvertedLandscape]; {$IFDEF IOS} Application.CreateForm(TF_MainiOS, F_MainiOS); {$ELSE} Application.CreateForm(TF_MainFMX, F_MainFMX); {$ENDIF} Application.Run; end. Zitat:
|
AW: GUI abhänging vom Target auswählen
Ich habe das für eine Anwendung so gelöst :
Delphi-Quellcode:
program TestDemo;
uses System.StartUpCopy, FMX.Forms, {$IFDEF IOS} iOSapi.UIKit, {$ENDIF } {$IFDEF ANDROID} FMX.Platform.Android, Androidapi.JNI.GraphicsContentViewText, {$ENDIF } PadForm in 'PadForm.pas' {PadMainForm}, PhoneForm in 'PhoneForm.pas' {PhoneMainForm}, CommonHelperUnit in 'units\CommonHelperUnit.pas'; {$R *.res} //////////////////////////////////////////////////////////////////////////////// /// /// To check if the app is running on an iPad /// {$IFDEF IOS} function IsPad: Boolean; begin Result := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice).userInterfaceIdiom = UIUserInterfaceIdiomPad; end; {$ENDIF} {$IFDEF ANDROID} function IsPad: Boolean; begin Result := (MainActivity.getResources.getConfiguration.screenLayout and TJConfiguration.JavaClass.SCREENLAYOUT_SIZE_MASK) >= TJConfiguration.JavaClass.SCREENLAYOUT_SIZE_LARGE; end; {$ENDIF} //////////////////////////////////////////////////////////////////////////////// /// /// Main Program /// begin Application.Initialize; Application.FormFactor.Orientations := [TFormOrientation.soPortrait, TFormOrientation.soInvertedPortrait, TFormOrientation.soLandscape, TFormOrientation.soInvertedLandscape]; if IsPad then Application.CreateForm(TPadMainForm, PadMainForm) else Application.CreateForm(TPhoneMainForm, PhoneMainForm); Application.Run; end. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:35 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz