0
votes

I'm writing a mobile application using Delphi XE6 and found in one of the examples in their repository the ability to have a Master view and alternate fmx views for different devices. The sample looked as it if would select the correct form based on compiler directives, but I cannot seem to get that to work. The interface looks great as I can have the Master form with the basic content, then implement inherited changes based on screen size and capabilities. There are icons when in this view such as Add View and Remove View. When selecting Add View, the dialog of all Android and iOS devices comes up allowing selection, then when selected it shows the additional views with an icon of the device background such as iPhone5. The unit then shows the multiple references like this:

implementation

uses Math;

{$R *.fmx}

{$R *.iPhone5.fmx IOS}

{$R *.Samsung_Galaxy_S4.fmx ANDROID}

The alternate views then show inherited properties from the Master form allowing you to alter values and include specific styles that match the platform. If this worked it would save so much effort. I'm currently having trouble with the TStyleBook as the iOSBlack style is not compatible with the Android and throws an error on the device. When using the AndroidDark style there is a similar issue on the iOS device. Has anyone had experience with this multiple view mode?

Thanks!

1
The sample you've shown is invalid on any platform or version of Delphi (it won't compile at all). Can you provide a specific link to the example in the repository you're describing? - Ken White
Compiles just fine in my XE6 Architect version. Note that all 3 fmx files must exist. The example is from [link](svn.code.sf.net/p/radstudiodemos/code/trunk/Object Pascal/Mobile Samples/User Interface/ListView) from the SampleListViewAddThumbAndCaptionProject project and specifically KeyboardDemoForm.pas. Screen shots of what it looks like here: link link - Randy Sill
I'm looking at AddThumbAndMainFormU.pas on my system now, and the implementation contains only uses System.Math; {$R *.fmx} before it declares constants and starts implementation of methods for TForm594. The 2nd and 3rd {$R}s don't exist. (The syntax shown is improper for {$R}, which is why I made my first comment. The proper syntax is {$R resourcefile resourcescript}, and * refers to the unit name. There are also no AddThumbAndCaptionMainFormU.iPhone.fmx or AddThumbAndCaptionMainFormU.Samsung_Galaxy_S4.fmx files, which would fail. Are they your files? - Ken White
I listed the wrong pas file but you caught that. I'm using TRUNK and not the XE6 branch from radstudiodemos, perhaps you are using the branch. The {$R *.fmx} {$R *.LgXhdpiPh.fmx ANDROID} is in AddThumbAndCaptionMainFormU.pas and i do have the AddThumbAndCaptionMainFormU.LgXhdpiPh.fmx file in my listview folder. They are in the repository. Perhaps this is a finally realized edit mode for XE7. - Randy Sill
Multiple device views is not an XE6 feature. Considering that the multi-view changes were checked in to the demos SVN by Spencer Kimball, who is an Embarcadero engineer, it is probably a safe bet to say that this is a new feature coming in XE7. - Remy Lebeau

1 Answers

0
votes

You should handle android and iOS specified code in your create method like so for your stylebooks:

{$IFDEF ANDROID}
stylebook := AndroidDarkStylebook;
{$ENDIF}
{$IFDEF IOS}
stylebook := iOSDarkStylebook;
{$ENDIF}