Recent

Author Topic: [SOLVED]Anyone knows how to launch a second jform?  (Read 3557 times)

amartitegui

  • Jr. Member
  • **
  • Posts: 84
[SOLVED]Anyone knows how to launch a second jform?
« on: December 18, 2017, 06:10:06 pm »
To "show a second jform... It should be made by launching activity I guess.. but how should the activity be called an referred?
Thanks to anyone knowing
« Last Edit: December 20, 2017, 05:09:30 pm by amartitegui »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: Anyone knows how to launch a second jform?
« Reply #1 on: December 18, 2017, 08:23:38 pm »
Hello  amartitegui!

there are more multi-form demo..... but

go to "......demo\GUI" and look fot  "AppTest1"   a multi-form demo example....

now, to start  a new activity look for "intents" demos ....

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

amartitegui

  • Jr. Member
  • **
  • Posts: 84
Re: Anyone knows how to launch a second jform?
« Reply #2 on: December 19, 2017, 05:44:41 pm »
I've checked. launching second form works great.
but i found a problem ...
 if trying to close second form (to go back to mainform). Result is app has found a problem and will be closed.

I do this to launch:
        if(id_detail= nil) then
          begin
            gApp.CreateForm(Tid_detail, id_detail);           
            id_detail.SetCloseCallBack(gps_sgtl_droidJNIPrompt, Self);
            id_detail.PromptOnBackKey:= False;
            id_detail.Init(gApp);
          end         
          else
          begin
            id_detail.Show;
          end;
             
also:
     
procedure Tgps_sgtl_droid.gps_sgtl_droidJNIPrompt(Sender: TObject);
begin
  preparagrid;
  text_search.Text:='';
end;     
               

Ideas?
thanks
« Last Edit: December 19, 2017, 05:48:03 pm by amartitegui »

amartitegui

  • Jr. Member
  • **
  • Posts: 84
Re: Anyone knows how to launch a second jform?
« Reply #3 on: December 19, 2017, 06:35:14 pm »
I'm a little confused about why this can happen....
I mean.... the SetCloseCallBack really is just an event handler rigth? therefore It shouldn't even be necessary. I tried to remove it like this:
  if(id_detail= nil) then
          begin
            gApp.CreateForm(Tid_detail, id_detail);           
            id_detail.SetCloseCallBack(gps_sgtl_droidJNIPrompt, Self);
            id_detail.PromptOnBackKey:= False;
            id_detail.Init(gApp);
          end         
          else
          begin
            id_detail.Show;
          end;     
       
So I was thinking that just by closing form should do. But same problem.
I'm I missing something?
jmpessoa,  probably u know best
thanks for any help

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: Anyone knows how to launch a second jform?
« Reply #4 on: December 19, 2017, 07:30:47 pm »

If you need only launcher a second form and not need a form result
after close it...

Code: Pascal  [Select][+][-]
  1. if(id_detail= nil) then
  2.            begin
  3.             gApp.CreateForm(Tid_detail, id_detail);          
  4.             id_detail.Init(gApp);
  5.           end        
  6.           else
  7.           begin
  8.             id_detail.Show;
  9.           end;            
  10.  
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

amartitegui

  • Jr. Member
  • **
  • Posts: 84
Re: Anyone knows how to launch a second jform?
« Reply #5 on: December 19, 2017, 07:55:05 pm »
thanks jmpessoa.
I just tried.... but same.

the launching its inside a procedure like this:
try
        if MySQL56Connection1.Connected then begin
          SQLQuery1.close;
          SQLQuery1.sql.text:='HERE A QUERY';
          SQLQuery1.active:=true;
          SQLQuery1.Open;
          with id_seleccionado do
          begin
           
              {GETTING VALUES FROM  QUERY}
          end;
          SQLQuery1.Close;
          if id_seleccionado.material_suelto=false then begin
           {ASIGNING OTHER VALUES}       
          if(id_detail= nil) then
          begin
            gApp.CreateForm(Tid_detail, id_detail);         
            id_detail.Init(gApp);
          end
          else
          begin
            id_detail.Show;
          end;         
          id_detail.user:=MySQL56Connection1.UserName;
          id_detail.pasword:=MySQL56Connection1.Password;   
          id_detail.popula_id(id_seleccionado);
          id_detail.popula_puerta(puerta_rescatada);
          end
          else begin
             ShowMessage('Material Suelto. Esta visión no está imprementada todavia. ')
          end;   
        end;
     finally
     end;


when It closes.... what does it really do. I mean. I guess that there is a problem when closing second form. or maybe when getting back to mainform.
What's supposed to do when closing form... ?
Its just to know if There is some data lost somewhere. (any variable that I may pass to a class in  {ASIGNING OTHER VALUES} ) or something.
'cause I dont really imagine why this may happen
thanks

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: Anyone knows how to launch a second jform?
« Reply #6 on: December 19, 2017, 08:45:50 pm »
here you launcher form id_detail:

Code: Pascal  [Select][+][-]
  1. if(id_detail= nil) then
  2.           begin
  3.             gApp.CreateForm(Tid_detail, id_detail);        
  4.             //Edited <<---- here you can initialize some form public property ...
  5.             id_detail.Init(gApp);    //<--- this will triger "OnJNIPrompt"  in id_detail form
  6.           end
  7.           else
  8.           begin
  9.             id_detail.Show;
  10.           end;        
  11.  

So, try move this code to  "OnJNIPrompt"  in id_detail form ...
Code: Pascal  [Select][+][-]
  1.           id_detail.user:=MySQL56Connection1.UserName;
  2.           id_detail.pasword:=MySQL56Connection1.Password;  
  3.           id_detail.popula_id(id_seleccionado);
  4.           id_detail.popula_puerta(puerta_rescatada);
  5.  
« Last Edit: December 19, 2017, 09:08:46 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

amartitegui

  • Jr. Member
  • **
  • Posts: 84
Re: Anyone knows how to launch a second jform?
« Reply #7 on: December 19, 2017, 09:04:09 pm »
Thanks man. Will tray that

amartitegui

  • Jr. Member
  • **
  • Posts: 84
[SOLVED]Re: Anyone knows how to launch a second jform?
« Reply #8 on: December 20, 2017, 05:06:06 pm »
Well Didnt work. And this is what I found.... dont know why.

I started new project. with same elements.
And put a button to go to second form.
And step by step adding components and see.

The problem looks that its because jGridView.
FIRST STEPS
I got 2 jGridViews. I dont do anything to the gridviews. just placed in dessign. no data in them... nothing.

Forms, both just with controls (graphic) and some variable declarations.

When hitting button opens second. and when clicking BACK comes to main again
Using:
 procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
    if(AndroidModule2= nil) then
    begin
      gApp.CreateForm(TAndroidModule2,AndroidModule2);
      AndroidModule2.Init(gApp);
    end
    else
    begin
      AndroidModule2.Show;
    end;
end;

SECOND STEP:
in JNIPrompt I make a call to :preparagrid
I set in main form:
procedure TAndroidModule1.preparagrid;
var
  row,col:integer;
begin
   with jGridView2 do begin
       Clear;
       ColCount:=8;
       row:=0;
       jGridView2.AddRow(row);
       jGridView2.Cells[0,row]:='ID';
       jGridView2.Cells[1,row]:='PEDIDO';
       jGridView2.Cells[2,row]:='CLIENTE';
       jGridView2.Cells[3,row]:='REF CLIENTE';
       jGridView2.Cells[4,row]:='SERVIDA';
       jGridView2.Cells[5,row]:='FORR HOJA';
       jGridView2.Cells[6,row]:='FORR BASTI';
       jGridView2.Cells[7,row]:='MAT SUELTO';
   end;
end;
         

AND FAILS.
so, what I have to do is set a boolean variable (grid_set_enable)
set to false at activitycreate
and in JniPrompt if its false I call preparagrid, and then set it to true.

NOW it works.


 

TinyPortal © 2005-2018