Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 16
Registered: ‎05-13-2013
My Device: 8240
My Carrier: vodafone

How to Delete message From popup screen

Hi All,


I have one simple button in my home screen which is used to display notification popup screen comes from webservices and it displays correctly but now there are two button in each notification accept and reject....


Now i want like when i click on either button my logic gets work and it should remove that perticular notification from popup window.... how to delete any field from popup screen and redisplay again when new notification arrives...

Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: How to Delete message From popup screen

You can use these functions at runtime - 

public void add(Field field)
public void delete(Field field)


Kanak Sony
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Posts: 16
Registered: ‎05-13-2013
My Device: 8240
My Carrier: vodafone

Re: How to Delete message From popup screen

this is my code can you explain by seeing this once again....


package com.syntel.expensemanager.ui;

import net.rim.device.api.system.Characters;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.PopupScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

final class NotificationPopUp extends PopupScreen implements FieldChangeListener{
public String[] arr = {};
private final static int _ALPHA = 0xBF;
boolean action_notification = true;
private static String[] objmember={" "};
public static String[] objvalue={" "};
ButtonField acceptBtn;
ButtonField rejectBtn;
public static String objgroup;
public static String objId;
VerticalFieldManager vfm;
int i;
public NotificationPopUp() {
super(new VerticalFieldManager());
| VerticalFieldManager.FIELD_HCENTER);


i= vfm.getIndex();


protected void paintBackground(Graphics g) {
XYRect myExtent = getExtent();
int color = g.getColor();
int alpha = g.getGlobalAlpha();
g.fillRect(0, 0, myExtent.width, myExtent.height);

protected boolean keyChar(char c, int status, int time) {
if (c == Characters.ESCAPE) {
return super.keyChar(c, status, time);

public static void setData(String[] description, String[] key) {
// TODO Auto-generated method stub
objmember = description;
objvalue = key;

public static void data(String groupname, String groupId) {
// TODO Auto-generated method stub
objgroup = groupname;
objId = groupId;

public void display() {
for (int i = 0; i < objmember.length; i++) {
LabelField lbl = new LabelField(objmember[i]);
if (objvalue[i] != "false") {
HorizontalFieldManager hfm = new HorizontalFieldManager();
acceptBtn = new ButtonField("accept");
rejectBtn = new ButtonField("reject");
vfm.add(new SeparatorField());
} else {
vfm.add(new SeparatorField());


public void fieldChanged(Field field, int context) {
// if(field.equals(acceptBtn)){
// vfm.delete(get)
// }


Posts: 17,003
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to Delete message From popup screen

you have a few issues there.
first, you iterate over objmember and re-use the acceptBtn and rejectBtn variables, which kind of defeats their purpose.
these will contain only the last two buttons that were generated.

I would suggest that you create one (new) vfm for each iteration and add this one, makes it a lot easier to remove them again as you don't have to remove each field on its own.

the main question is: how do you reference the manager?
you could go through the hierarchy, calling getManager on the button would give you the hfm, calling getManager on that the vfm, calling getManager on that again the screen. you could then call delete() on the screen with the vfm you retrieved before.

or you could use setCookie on the created buttonFields to store a reference to the vfm and directly call delete with it.

or use a custom data structure like a hashtable.
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter