Recent

Author Topic: Help with tablayout.gettitle()  (Read 956 times)

Narciso

  • New member
  • *
  • Posts: 7
Help with tablayout.gettitle()
« on: January 24, 2025, 05:29:43 pm »
in this procedure S (VAriable) result always '' (Nullstring) , WHY?
Code: Pascal  [Select][+][-]
  1. function TAndroidModule1.TabExists(itemTitle: string): Boolean;
  2. var
  3.   i: Integer;
  4.   s: string;
  5. begin
  6.   Result := False;
  7.   for i := 0 to TabLayout1.GetTabCount() - 1 do
  8.   begin
  9.     s:= TabLayout1.GetTitle(i);
  10.     showmessage(s+' = '+ itemtitle);
  11.     if s = itemTitle then
  12.     begin
  13.       Result := True;
  14.       Break;
  15.     end;
  16.   end;      
  17.  

c4p

  • Full Member
  • ***
  • Posts: 170
Re: Help with tablayout.gettitle()
« Reply #1 on: February 01, 2025, 10:32:54 am »
TabLayout1.GetTitle does not appear to return the tab title in LAMW unfortunately, which is why you have run into this issue, I ran into that too, a possible (messy) workaround is when you add (or remove) your tabs like Tablayout1.AddTab('TitleName') to put the title text into a TStringList, or something similar at the same time and then search through that list instead to see if the tab title exists?
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle.

Narciso

  • New member
  • *
  • Posts: 7
Re: Help with tablayout.gettitle()
« Reply #2 on: February 01, 2025, 05:26:48 pm »
very strange , a function that do nothing but exists.. thank you for suggest, i also think that the simplest way is a support stringlist, but its very nasty. 

jmpessoa

  • Hero Member
  • *****
  • Posts: 2320
Re: Help with tablayout.gettitle()
« Reply #3 on: February 01, 2025, 10:38:05 pm »

Fixed!

added the missing ""GetTitle" to file  "jsTabLayout.java"

Code: Java  [Select][+][-]
  1. public String GetTitle(int _position) {
  2.       return GetText(_position);
  3.   }
  4.  
  5.  

Thanks to All!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

c4p

  • Full Member
  • ***
  • Posts: 170
Re: Help with tablayout.gettitle()
« Reply #4 on: February 02, 2025, 09:24:47 am »
Thank you @jmpessoa  :)
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle.

Narciso

  • New member
  • *
  • Posts: 7
Re: Help with tablayout.gettitle()
« Reply #5 on: February 02, 2025, 06:10:43 pm »
to solve the matter must i reinstall all lamw or only rewite the file jstablayout.java?

jmpessoa

  • Hero Member
  • *****
  • Posts: 2320
Re: Help with tablayout.gettitle()
« Reply #6 on: February 02, 2025, 06:17:31 pm »

Yes, you can simply add the missing method

Code: Java  [Select][+][-]
  1. public String GetTitle(int _position) {
  2.       return GetText(_position);
  3. }
  4.  

to "jstablayout.java"  in LAMW folder "....\android_wizard\smartdesigner\java"
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Narciso

  • New member
  • *
  • Posts: 7
Re: Help with tablayout.gettitle()
« Reply #7 on: February 02, 2025, 11:28:20 pm »
tank you, should be a good idea add a function like this:
tablayout.indexof(tablename)

 

TinyPortal © 2005-2018