BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 04-05-2008, 07:20 AM   #1
bba
Knows Where the Search Button Is
 
Join Date: Apr 2008
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 28
Question Delete item from ListField

Please Login to Remove!

Hello,
how do I delete just a single item from a ListField?
I tried this but it doesn't work:

Code:
     public class ListCallback implements ListFieldCallback {
            public Vector listElements = new Vector();
            
   public void drawListRow(ListField list, Graphics g,  int index, int y, int w) {  
      String text = (String)listElements.elementAt(index);
      g.drawText(text, 0, y, 0, w);  
   }
      
   public Object get(ListField list, int index) {  
      return listElements.elementAt(index); 
   }     

   public int indexOfList(ListField list, String p, int s) {  
      //return listElements.getSelectedIndex();
      return listElements.indexOf(p, s);  
      
   }
      
   public int getPreferredWidth(ListField list) {  
      return Graphics.getScreenWidth();  
   }
      
   public void insert(String toInsert, int index) {  
      listElements.insertElementAt(toInsert, index);  
   }
      
   public void erase() {  
      listElements.removeAllElements();  
   }
   
   public void eraseAt(int index) {  
      listElements.removeElementAt(index);
     
   }
}
well this was just the declaration, now the code to delete the selected item:

Code:
myCallback.eraseAt(myList.getSelectedIndex());
why doesn't it work?
is there a way to delete the selected item from the list?

thank you guys in advance!

Murene
Offline  
Old 04-05-2008, 10:52 AM   #2
akosnitzky
BBF Moderator
 
akosnitzky's Avatar
 
Join Date: Jul 2005
Location: Southern Florida
Model: 9650
OS: 6.0.0.333
Carrier: Verizon BIS
Posts: 14,484
Default

Wirelessly posted (Verizon 8830)

X
__________________
------
Follow @akosnitzky on Twitter

LET'S GO CANES!

Last edited by akosnitzky; 04-05-2008 at 10:54 AM..
Offline  
Old 04-05-2008, 12:36 PM   #3
bba
Knows Where the Search Button Is
 
Join Date: Apr 2008
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 28
Default

what are you trying to say ;)?
Offline  
Old 04-07-2008, 01:20 AM   #4
sunnan
Thumbs Must Hurt
 
Join Date: Nov 2007
Model: 8100
PIN: N/A
Carrier: vodafone
Posts: 61
Default

int index = myList.getSelectedindex();
myList.delete(index);
myCallback.eraseAt(index);

Last edited by sunnan; 04-07-2008 at 01:21 AM..
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Original New DEC Digital DCJ11-AE 57-19400-09 Vintage CPU x 1pc picture

Original New DEC Digital DCJ11-AE 57-19400-09 Vintage CPU x 1pc

$100.00



DEC DIGITAL VINTAGE RA8X Control Panel picture

DEC DIGITAL VINTAGE RA8X Control Panel

$30.00



Vintage Journal Beautiful Garden Flower Embossed Leather-Antique Handmade Dec... picture

Vintage Journal Beautiful Garden Flower Embossed Leather-Antique Handmade Dec...

$29.04



DEC / AMI 304E 21-15542-01 vintage ceramic IC - KTF11 Chip *NEW* 40278101  picture

DEC / AMI 304E 21-15542-01 vintage ceramic IC - KTF11 Chip *NEW* 40278101

$50.00



Dec/Adac Corp. D4-10390 Rev 6 Model 1664ATTL Output Pulse Board 1983 (B16) picture

Dec/Adac Corp. D4-10390 Rev 6 Model 1664ATTL Output Pulse Board 1983 (B16)

$189.99



VINTAGE Bruker Board DEC W4P3042 for SpectroSpin 250 picture

VINTAGE Bruker Board DEC W4P3042 for SpectroSpin 250

$50.00







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.