NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 33 34 35 36 37 … 93 Next »
WizUiList - Removing an Item

 
  • 0 Vote(s) - 0 Average
WizUiList - Removing an Item
Ommina
Offline

Senior Member

Posts: 330
Threads: 39
Joined: Feb 2006
#1
2008-03-26, 06:17 AM
One for JavaWiz:

Presumably I'm missing the obvious, but is there a way to remove an individual item from a populated WizUiList ?

So far I've tried various combinations of RemoveAt from the getItemList ArrayList (no effect), creating a new ArrayList and adding the ListItem one a time, then assigning the new list back to setList, but that didn't work either.

Any actions on the underlying ArrayList seemed to be ignored, while trying to assign a new list based on the old one gives me a list of "@text". Now, granted, it is the right number of @text lines, but still not quite what I was hoping to achieve.

I tried assigning null to setListItem, but that made it REALLY unhappy.

ClearSelected looked tempting, but only after trying it out did I realize that wasn't the meaning of Clear that I was looking for.

I'm sure I'm just missing something, but can you point me in the right direction?

Thanks!
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#2
2008-03-30, 06:50 PM
Ommina Wrote:One for JavaWiz:

Presumably I'm missing the obvious, but is there a way to remove an individual item from a populated WizUiList ?

So far I've tried various combinations of RemoveAt from the getItemList ArrayList (no effect), creating a new ArrayList and adding the ListItem one a time, then assigning the new list back to setList, but that didn't work either.

Any actions on the underlying ArrayList seemed to be ignored, while trying to assign a new list based on the old one gives me a list of "@text". Now, granted, it is the right number of @text lines, but still not quite what I was hoping to achieve.

I tried assigning null to setListItem, but that made it REALLY unhappy.

ClearSelected looked tempting, but only after trying it out did I realize that wasn't the meaning of Clear that I was looking for.

I'm sure I'm just missing something, but can you point me in the right direction?

Thanks!

Sorry, missed this question...

Hmm... There is no direct way of removing a single item in the list. (I will probably add a .Remove(idx) method at some point). Here is a way to do it (myList is a WizUiList object):
Code:
//
// Remove item at specific location
int idx = 2;
ArrayList list = myList.getItemList()'
list.RemoveAt(idx);
myList.setItemList(list);

//-----------------------------------
// Remove specific object item
WizUiListItem item = (WizUiListItem)myList.getCurrentItem();
if (item != null)
{
    list.Remove(item);
    myList.setItemList(list);
}
Ommina
Offline

Senior Member

Posts: 330
Threads: 39
Joined: Feb 2006
#3
2008-03-30, 07:46 PM
Hey there! Thanks for the reply -- was thinking of /pokeing it later today.

I actually tried the first route earlier (via RemoveAt on the list), but after doing the setItemList afterwards, the visual UI itself no longer renders correctly.

Each line is replaced with "@text" -- that is, for every item I have in the UiList, I now have a line with text that reads "@text". The count is correct, but the label isn't.

I'm going to load it up in a few minutes and go through it again to ensure I wasn't doing something silly, and will also give the Remove(object) style a go as well.

(After a cup of coffee.)
Ommina
Offline

Senior Member

Posts: 330
Threads: 39
Joined: Feb 2006
#4
2008-03-31, 06:23 AM
OK, a cup of coffee and an afternoon of other stuff. But I have an update at least.

Both of the methods suggested yield the same "@text" problem as described above.

So to do some testing, I looped through the getItemList collection, manually adding each item to my local ArrayList, checking its type and .text value as I went along.

They were added to my ArrayList fine. BUT, if I dump the same ArrayList after calling the .setItemList, all the .text values are cleared.

My conjecture at this point is that getItemList is returning a reference to an internal list, and when that internal list is cleared with setItemList, the references go away with it. (That's my guess anyway. You'll have to confirm or deny that.)

In the end, I created copies of each list item before adding them to my ArrayList, then assigned those copies back via setItemList, and that worked.

It seems a bit convoluted, and I still may be making it more difficult than it needs to be, but right now I'm not seeing any other way. (Or maybe I should have had more coffee earlier...!)
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I catch the event where a list item is selected? mkenyon2 3 1,401 2009-01-06, 06:36 PM
Last Post: sub
  Menu item Two_Edge 3 1,797 2008-04-28, 11:59 PM
Last Post: sub

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode