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
arunbiet
Posts: 384
Registered: ‎06-22-2010
My Device: na

Picturescroll image index issue

I have a CustomListField.Its working fine apart from the fact that when i click the image and try to get the index,its not giving the proper index.If the click in the left portion of the image,i can get the correct index,but if i click the right portion,it gives me the index of the next image.Here is my code.Can anyone help ?

 

cfg=new CustomPictureScrollField( mCtaegory.size(), bmp,85,80,405, 120){
			protected void onUnfocus(){
			    /*do nothing to prevent BB default image highlight*/
			    /*or do your own thing*/
			}
			
			  protected boolean touchEvent(TouchEvent message) {
				  super.touchEvent(message);
		            if (TouchEvent.CLICK == message.getEvent()) {
		                FieldChangeListener listener = getChangeListener();
		                if (null != listener)                       
		                    listener.fieldChanged(this, 1);
		                    return true;
		            }
		            return false;
		        }              
		};
		cfg.setChangeListener(new FieldChangeListener() {          
		        public void fieldChanged(Field field, int context) {                
		           if (context == 1) {
		        	   UiApplication.getUiApplication().invokeLater(new Runnable() {
							public void run() {
								int imgIndex=cfg.getCurrentImageIndex();
								Hashtable hs = (Hashtable) mCtaegory.elementAt(imgIndex);
								SubCategory.gid = (String) hs.get("catid");
								SubCategory.title = (String) hs.get("title");
								UiApplication.getUiApplication().pushScreen(new SubCategory());

							}
						});
		            }
		        }
		    });

 

Developer
arunbiet
Posts: 384
Registered: ‎06-22-2010
My Device: na

Re: Picturescroll image index issue

Do anyone have some idea this problem?