FMXNavBar won't stay in order on android

Hi, I'm having trouble keeping the navbar in the order I put it in. I have 5 panels and they keep jumping in different order, either in design time and/or run time:


* in design time, they are in order, but at run time they are out of order.
* in design time, they are out of order and in run time they are out of order.
* in design time, they are in order, but at run time, on occasion they are in order or out of order.

In design mode, when I lay it out, it is in order. I name the captions in order, to help me keep things in sync of what they will do. Example

navbarPanel0
navbarPanel1
navbarPanel2
navbarPanel3
navbarPanel4

The random order of the panels also causes my app to crash and close down (because I have listview's inside each panel and each are connected via livebinding and through sql script they call the next query, but if it calls the wrong query because the panels are out of order or scrambled, the app crashes and closes down). This is very annoying 

What can I do to stop this from happening ?

Is there code that I can write in the form's create event or something ?

Windows 7 home prem, 64-bit, Delphi XE7 Pro with Update 1 and mobile add-on pack.

Thank you.

Hi, 


We have investigated this here but are not able to reproduce this.
Can you perhaps send us a sample that is able to reproduce this? Are you able to reproduce this in a new project with a new instance of TTMSFMXNavBar?

Kind Regards, 
Pieter

The issue is difficult to explain and reproduce. I've seen this happen a few times before but can't exactly nail down the cause except to say that whenever you start moving the control around, i.e., setting the Align to different values, saving it, reopening to do more work, saving, moving the control on the form, left side, right side, client, resizing it for Windows, resizing it for Android, compiling it for different Android tablets (LG Pad 7" kitkat 4.4.2 800x1200, Acer Iconia Tab 8 kitkat 4.4.4 800x1200, and Dell Venue 8 1200x1900 kitkat 4.4.4) and the list goes on with respect to doing various work on the project. 


My only way to resolve it was to rebuild the whole project from scratch and thats not something I want to keep doing for every project I'm working on. But in the project I am working on, I am too deep in the design, changes and upgrades, to rebuild from scratch all over again. And, the problem with rebuilding the navbar is having to do with the listviews, since they are each connected to a livebinding query.  Even removing and rebuilding a panel in the navbar requires me to rebuild the listview and query and livebinding connections. Its a lot of work to have to do everything navbar panels decide to scramble their placement order. Otherwise, I don't know whatever to do except to rebuild the project all over again.   The navbar is the center point of the application, for both windows and android. And without the navbar, there is no tool or else I would have to build it without the navbar and have all the listviews showing in the apps window, (very messy). Its much more tidier and elegant looking to use the navbar.  

This is possible an issue when converting a project from an older version of RAD Studio to a new version of RAD Studio. It's unclear why this causes issues, but in various cases the issue is fixed by creating a new project in the active development environment. You could also try to create the TTMSFMXNavBar programmatically and assign the parent of each list in the constructor of the form to the correct page. This way you can avoid having to redesign each form when upgrading to a newer version of RAD Studio in the future. If the issue is reproducible in a separate new project then you can always send it so we can investigate here.


Kind Regards, 
Pieter

Update..


Hello. Sorry for the delay. 
>> This is possible an issue when converting a project from an older version of RAD Studio to a new version of RAD Studio. It's unclear why this causes issues, but in various cases the issue is fixed by creating a new project in the active development environment. 

I am not sure it was because of this. But at the time of the problem, I had uninstalled xe7 in order to install the xe7 Update 1. That was when the order got scrambled.   And, whenever I would recreate the project, the issue would come and go.   But a few days I discovered another way to resolve it. 

var
  Form1: TForm1;
  sSQL : string;
  DBPath: string;


implementation


{$R *.fmx}
{$R *.LgXhdpiTb.fmx ANDROID}
{$R *.XLgXhdpiTb.fmx ANDROID}


procedure TForm1.FormCreate(Sender: TObject);
begin
  //
  //navbar.ActiveTabIndex:=0;
end;

In the above code sipppet, I remove the following: 

{$R *.LgXhdpiTb.fmx ANDROID}
{$R *.XLgXhdpiTb.fmx ANDROID}

And the issue went away.  I don't know where or when these two lines got added because I know I never added them since I know nothing about it. Anyway. The problem seems to have resolved, so far so good and its been several weeks or longer now without the issue. 

Thank you for your help.
JohnLM

Hi, 


Thank you for your feedback, we will further investigate why this issue comes up when adding forms for different Operating Systems.

Kind Regards, 
Pieter

Hi, I am just reporting that I am experiencing the same problem.  The tab ordering is randomly scrambled again. 


I spent all day trying to figure it out.  Then, I found remembered this forum post and discovered that the project had inserted the code: {$R *.XLgXhdpiTb.fmx ANDROID} 

it inserted it under this section: 

implementation

{$R *.fmx}
{$R *.XLgXhdpiTb.fmx ANDROID}  <--- I removed this line only, and the problem went away!

I am not sure what {$R *.XLgXhdpiTb.fmx ANDROID} does for my project, and if I remove it, what consequence would I suffer, if any ?

Otherwise, I will just leave it out because its the only way I can run the app on an android correctly in the navbar's tab's ordering. 

TTMSFMXNavBar version 1.5.0.3 

Hi, 


This file is added when switching the Master view to another view. Each view has a separate fmx file.

Kind Regards, 
Pieter

ok. Now I am plagued by this issue again. And this time, it seems to be permanent. 


To display the correct browser component at the proper time (for windows or android) I added the following code snippet in my btnPrintPreview event: 

procedure TForm1.btnPrintPreviewClick(Sender: TObject);
var
  DPath: string;
begin
  DPath   := TPath.GetHomePath + PathDelim + 'manifest.html';
  // convert to html and save in default path
  datagridManifest.ExportHtml(Dpath);
  // tell the routine we are opening a file.
  DPath   := 'file:///'+DPath;
  // set the actual TAB active for the browser preview to show manifest.html
  tabcontrol1.TabIndex:=1;
  // refresh .html file with latest info from manifest.html file def path.
  txtURL.Text := DPath;
  // now, if we are in windows, lets use the TMS browser control, else
  // we use the twebbrowser from delphi in Android.
{$ifdef MSWINDOWS}
  wb1.Visible    := false;
  wb1tms.Visible := true;
  wb1tms.URL     := dpath;
  wb1tms.Navigate;
{$endif}
  // if we are in Android device, display the twebbrowser
{$ifdef ANDROID}
  wb1tms.Visible := false;
  wb1.Visible    := true;
  wb1.URL := dpath;
  wb1.Navigate;
{$endif}
end;

the code that I actually added are here: 

{$ifdef MSWINDOWS}
  wb1.Visible    := false;
  wb1tms.Visible := true;
  wb1tms.URL     := dpath;
  wb1tms.Navigate;
{$endif}
  // if we are in Android device, display the twebbrowser
{$ifdef ANDROID}
  wb1tms.Visible := false;
  wb1.Visible    := true;
  wb1.URL := dpath;
  wb1.Navigate;
{$endif}

Please help me fix this. I can't keep recreating the navbar and all its UI controls, queries, and underlining livbinding connections. Its too complex at this stage to delete the navbar control and start from scratch again. 

The panels are showing in random order again: 
[1.row] -> [initialize button] -> [connection button]
[3.row]
[5.row]
[2.row]
[4.row]

when they should be in this order: 
[5.row]
[4.row]
[3.row]
[2.row]
[1.row] -> [initialize button] -> [connection button]

This is a deal breaker for me with this component. 

>> You could also try to create the TTMSFMXNavBar programmatically and assign the parent of each list in the constructor of the form to the correct page. 

This is too complex for me to do. I don't know anything about constructors and parents and things. That is beyond my knowledge. And I'm in a time crunch. We are way behind schedule due to these kinds of problems. 

Can you please provide me with some code to manually re-store (resort) the panels. Even if it doesn't show in the design view correctly, at least at run-time, it will show correctly. But I can't rebuild the navbar again! Its a nightmare to set up and working correctly. Thank you. 

Unfortunately we are not able to reproduce this here, not in an existing and not in a new project, so it's unclear how this issue can be reproduced, but the easiest workaround is to use SendToBack and BringToFront programmatically to try and re-order the panels in the correct order before displaying the navbar.


Kind Regards, 
Pieter
A thought occurred to me yesterday about looking at the "Unit1.fmx" file in this project. I searched for the navbar entries and after reviewing it against a previous project builds, (eg, i name project version folders, v01, v02, ... v05 when I want to start at another junction in the project, this way I can go back to the previous project and fix something that broke. But unfortunately, this time, I did not start another project version but instead, I continued with adding additional code and UI controls, plus test experiments, etc., and by the time I realized what happened, it was too late). Anyway. 

So, I compared the .fmx file against a previous .fmx file. The theory was, that since I did not make any changes to the navbar in several versions, I could see if any of the values were different or miss-placed somehow.  And as it turns out, they were. I found that the panel sections got reordered and that certain values within them (see below) were swapped around. 

Example of the fields that I found inconsistencies in the panel section of the Unit1.fmx file: 

TabOrder = 4
Caption = '4.row'
Sections = <>
PanelIndex = 3

Although I can't put my finger on the exact cause, It appears that something is 'refreshing' the .dfm file at different points in time.  Maybe during compiling, or closing, or when platforms compilations are changed or when used with {$ifdef android / mswindows / ios} are used, for instance. 

At this time, the navbar will not display in android when I compile for that platform. I don't know what happened to it, and I'm still reviewing how to fix it.  But it displays correctly when I compile for the windows platform. I'm stumpped at the moment with the navbar not displaying in android. 

The next time this happens, I will send the file(s) to you for review. 

>> but the easiest workaround is to use SendToBack and BringToFront programmatically to try and re-order the panels in the correct order before displaying the navbar.

I will also look into that next time, thank you. 

I was able use a previous project build to get the navbar working correctly as before. I just have to be more careful and keep synchronized backups.  As always, thank you for your support.