Recent

Author Topic: jListView.GetCheckedItemPosition always returns -1  (Read 598 times)

Thyphoon

  • New Member
  • *
  • Posts: 37
jListView.GetCheckedItemPosition always returns -1
« on: July 10, 2020, 12:11:11 am »
Today I updated lawn and when I compiled a project of mine I noticed that jListView.GetCheckedItemPosition is always returning -1, maybe I has something to do with a recent update?

jmpessoa

  • Hero Member
  • *****
  • Posts: 1624
Re: jListView.GetCheckedItemPosition always returns -1
« Reply #1 on: July 10, 2020, 04:12:00 am »

Can you do some diff in  "jListView.java"   for  "GetCheckedItemPosition"?

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

Thyphoon

  • New Member
  • *
  • Posts: 37
Re: jListView.GetCheckedItemPosition always returns -1
« Reply #2 on: July 14, 2020, 05:02:52 pm »
Like this?

Code: Pascal  [Select][+][-]
  1.  
  2. -      
  3. -       // Fix GetCheckedItemPosition [by TR3E]
  4. +                      
  5.         public int GetCheckedItemPosition() {
  6.                
  7.                 for( int i = 0; i < alist.size(); i++ )
  8. -                        if( alist.get(i).checked )
  9. -                                return i;
  10. -                      
  11. +                if( alist.get(i).checked )
  12. +                        return i;
  13. +              
  14.                 return -1;
  15.         }      
  16.  
  17.  

It doesnt seems to have changed...

But whenever I use GetCheckedItemPosition it returns -1  wherever there is a item selected or not.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1624
Re: jListView.GetCheckedItemPosition always returns -1
« Reply #3 on: July 14, 2020, 06:06:44 pm »

Quote
// Fix GetCheckedItemPosition [by TR3E] ...

Maybe   @TR3E  can help here....

[Please,  if possible]  Can you do a simple project/example   and put it in some open drive?

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

Thyphoon

  • New Member
  • *
  • Posts: 37
Re: jListView.GetCheckedItemPosition always returns -1
« Reply #4 on: July 15, 2020, 03:05:14 pm »
Sure!

https://drive.google.com/file/d/1qKlyz2DQ5IL67Zad0cU4NthaeRvn5zWg/view?usp=sharing

if I compile this with an older version of LAWN, GetCheckedItemPosition returns the checked item position ok.

Thyphoon

  • New Member
  • *
  • Posts: 37
Re: jListView.GetCheckedItemPosition always returns -1
« Reply #5 on: July 15, 2020, 06:45:18 pm »
I changed GetCheckedItemPosition  for GetItemIndex, I was misusing GetCheckedItemPosition to get the Index of the selected item and Adiv fixed it, sorry.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1624
Re: jListView.GetCheckedItemPosition always returns -1
« Reply #6 on: July 15, 2020, 08:42:50 pm »

Ok!

Have a good time!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

 

TinyPortal © 2005-2018