Recent

Author Topic: [REOPEN] How to add item to jListView in an arbitrary position  (Read 1303 times)

jluixjurado

  • New Member
  • *
  • Posts: 21
[REOPEN] How to add item to jListView in an arbitrary position
« on: September 13, 2022, 03:17:16 pm »
Hi!

I've just begun with LAMW and it's amazing!

One of my first tests has been with jListViews and I'm blocked with this problem: When I try to insert a new item in a certain position, like 0 (the jListView has more than one item), I haven't found any method to do that so, I tried with

   jlvList1.Items.Insert(0,'Hello');

Although it doesn't raise any exception, nothing happends !?

After that I tried updating the component with jListView1.invalidate, with jListView1Refresh, with jListView1.updateJNI(gApp), with jListView1.UpdateLayout, ... without any luck.

Can it be achieved any way without clearing the component and adding all items again?

Thanks in advance for your answers.
« Last Edit: October 03, 2022, 07:45:15 pm by jluixjurado »

rsu333

  • Full Member
  • ***
  • Posts: 110
Re: How to add item to jListView in an arbitrary position
« Reply #1 on: September 13, 2022, 03:37:22 pm »
I think add(' item') work , As new user  face this type of problem ,is common so we can check this
like listview1.(here we get list of command) then test it. (Same with edittext1 ,textview etc)
LAMW is very easy to use and learn  yet working perfectly.
Thanks LAMW team.

jluixjurado

  • New Member
  • *
  • Posts: 21
Re: How to add item to jListView in an arbitrary position
« Reply #2 on: September 13, 2022, 05:02:13 pm »
But add(item') adds the item at the end of the jListview, and I want to put it in an arbitrary position (the first one, for instance)

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: How to add item to jListView in an arbitrary position
« Reply #3 on: September 13, 2022, 11:43:49 pm »

Quote
I want to put it in an arbitrary position....

Done!

Now there is a new "Insert" method!

Please, update your LAMW from github...

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

Mongkey

  • Sr. Member
  • ****
  • Posts: 430
Re: How to add item to jListView in an arbitrary position
« Reply #4 on: September 15, 2022, 08:06:44 am »

Quote
I want to put it in an arbitrary position....

Done!

Now there is a new "Insert" method!

Please, update your LAMW from github...

Thank You!

does my report bug on smartdesigner insertion plugin already done also?

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: How to add item to jListView in an arbitrary position
« Reply #5 on: September 15, 2022, 08:33:26 am »
Quote
does my report bug on smartdesigner insertion plugin already done also?

Yes!

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

Mongkey

  • Sr. Member
  • ****
  • Posts: 430
Re: How to add item to jListView in an arbitrary position
« Reply #6 on: September 16, 2022, 01:08:50 am »
thank you very much, on Bluetooth connection also got bugs, very hard to connect, but i got the proper one. i post proper code here, thank you. it is very useful for doing wireless  thermal printing for receipt. But by the way what are the advantages of using kotlin on LAMW?
« Last Edit: September 16, 2022, 01:13:35 am by Mongkey »

jluixjurado

  • New Member
  • *
  • Posts: 21
Re: How to add item to jListView in an arbitrary position
« Reply #7 on: September 16, 2022, 03:59:03 pm »
Thank you very much! Such an incredible piece of work!

jluixjurado

  • New Member
  • *
  • Posts: 21
Re: How to add item to jListView in an arbitrary position
« Reply #8 on: October 01, 2022, 08:10:47 pm »
Hello!

@jmpessoa , I think there could be something wrong with the new Inserrt method you added some days ago to jListView.

In fact, the method works as expected and adds a new item in the specified position but ... it seems that then you cannot use jListview.delete method properly! The item is not deleted at all! For example, if you put 3 jButtons (Button1, Button2 and Button3) and a jListView (ListView1) in an empty module (AndroidModule1) and add the next code:

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.Button1Click(Sender: TObject);
  2. begin
  3.   ListView1.Add('Added '+intToStr(ListView1.count));
  4. end;
  5.  
  6. procedure TAndroidModule1.Button2Click(Sender: TObject);
  7. begin
  8.   ListView1.delete(0);
  9. end;
  10.  
  11. procedure TAndroidModule1.Button3Click(Sender: TObject);
  12. begin
  13.   ListView1.Insert(0,'Inserted in 0');
  14. end;


and runs it:

if you Adds, lets say,three items with Button1, then you can delete the three pressing Button2
If you now Insert, lets say, three items with Button3, then you CAN'T delete any one pressing Button2
If you reopen the app and Add 3 items with Button1 and then Insert other three items with Button3 (or viceversa or in any other order) then you can ONLY delete the three first items.

It looks like when inserting items the control doesn't increase the count of them so, even having 6 items (for example), it's only capable of deleting three of them.

Am I right or am I doing something wrong?

Thanks in advance.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: [REOPEN] How to add item to jListView in an arbitrary position
« Reply #9 on: October 08, 2022, 06:23:17 pm »
Quote
Am I right or am I doing something wrong?

Well, I think that you are  correct ..

 
 I'll try to understand what's going on...
« Last Edit: October 08, 2022, 06:26:28 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jluixjurado

  • New Member
  • *
  • Posts: 21
Re: [REOPEN] How to add item to jListView in an arbitrary position
« Reply #10 on: October 12, 2022, 10:57:56 am »
Thank you very much.

If you think any help, don't hesitate to ask me for it!

 

TinyPortal © 2005-2018