Lazarus

Programming => Operating Systems => Android => Topic started by: Thyphoon on July 10, 2020, 12:11:11 am

Title: jListView.GetCheckedItemPosition always returns -1
Post by: Thyphoon 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?
Title: Re: jListView.GetCheckedItemPosition always returns -1
Post by: jmpessoa on July 10, 2020, 04:12:00 am

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

[LAMW folder "...\android_wizard\smartdesigner\java" ]
Title: Re: jListView.GetCheckedItemPosition always returns -1
Post by: Thyphoon 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.
Title: Re: jListView.GetCheckedItemPosition always returns -1
Post by: jmpessoa 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!
Title: Re: jListView.GetCheckedItemPosition always returns -1
Post by: Thyphoon 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.
Title: Re: jListView.GetCheckedItemPosition always returns -1
Post by: Thyphoon 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.
Title: Re: jListView.GetCheckedItemPosition always returns -1
Post by: jmpessoa on July 15, 2020, 08:42:50 pm

Ok!

Have a good time!
TinyPortal © 2005-2018