Welcome!

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

Reply
Developer
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10
My Carrier: Airtel

List row clicking is not working in the popup screen

Hi,

 

I am trying to put a listfield in the pop up screen. The list is coming properly. But when i am clicking a particular row of the list, it is not firing any event. itried with showing a dialog. but it is also not working. Here is my code:  

 

public class AttachmentListPopup  extends PopupScreen implements FieldChangeListener{

	private ListField _listField;
	 private Vector _listElements;
	public AttachmentListPopup()
	{
		super(new VerticalFieldManager());
		_listElements = new Vector(); 
		_listField = new ListField();
		ListCallback _callback = new ListCallback()
		{
			
			 public boolean navigationClick(int status, int time)
			 {
			    	int index = _listField.getSelectedIndex();
			    	if(index == 0)
			    	{
//			    		UiApplication.getUiApplication().popScreen();
			    		Dialog.alert("Grocery Clicked");
			    	}
			    	
			    	else if(index == 0)
			    	{
			    		Dialog.alert("To Do's Clicked");
			    	}
			    	return super.navigationClick(status, time);
			 }
		};
		_listField.setCallback(_callback);
		initializeList();
		add(_listField);
	}
	
	private void initializeList()
	{
	    String itemOne = "Grocery";
	    String itemTwo = "To Do's";
	    _listElements.addElement(itemOne);
	    _listElements.addElement(itemTwo);
	    _listField.setSize(_listElements.size());
	    _listField.setRowHeight(Display.getHeight()/6);
	}
	
	private class ListCallback implements ListFieldCallback 
	{
	    public void drawListRow(ListField list, Graphics g, int index, int y, int w) 
	    {
	    	y = y +20;
	        String text = (String)_listElements.elementAt(index); 
	        g.drawText(text, (Display.getWidth() - getFont().getAdvance(text))/2, y, 0 , w); 
	    } 
	    public boolean navigationClick(int status, int time) {
			// TODO Auto-generated method stub
			return false;
		}
		public Object get(ListField list, int index) 
	    {
	        return _listElements.elementAt(index); 
	    } 
	    public int indexOfList(ListField list, String prefix, int string) 
	    { 
	        return _listElements.indexOf(prefix, string); 
	    } 
	    public int getPreferredWidth(ListField list) 
	    { 
	        return Display.getWidth(); 
	    } 
	}
	public void fieldChanged(Field field, int context) {
		// TODO Auto-generated method stub
		
	}

}

 

 

please help..

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

Re: List row clicking is not working in the popup screen

don't return false when not handling navigationclick, return super.
use the debugger to check if your navigationclick handler is called.
----------------------------------------------------------
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