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
Regular Contributor
Posts: 92
Registered: ‎01-31-2012
My Device: curve 8520
My Carrier: vodafone

change listener problem

first time to face problem like this, I add change listener to the field but it didn't respond when I clicked on it !!!

 

that's the code I use

 

that's the navigation on click method as I use labels as tabs

 

protected boolean navigationClick(int status, int time) {
		// TODO Auto-generated method stub
		Field focus = UiApplication.getUiApplication().getActiveScreen()
				.getLeafFieldWithFocus();
		if (focus instanceof LabelField) {
			final int index = focus.getIndex() / 2;

			Thread th = new Thread(new Runnable() {

				public void run() {
					// TODO Auto-generated method stub
					new Connection(catsBeans[index].getLink(), "items");
					UiApplication.getUiApplication().invokeLater(
							new Runnable() {

								public void run() {
									// TODO Auto-generated method stub
									getMainManager().deleteAll();
									addItems();
								}
							});
				}

			});
			th.start();

		}

 and that's the addItems method which I add the listener

 

public void addItems() {
		showLoadingScreen();
		add(hfm);
		items = appManger.getItemsBean();
		newsTitle = new ItemsTitle[items.length];
		for (int i = 0; i < items.length; i++) {

			newsTitle[i] = ItemsTitle.getNewInstance(items[i],
					ItemsTitle.SMALL_SIZE);
			newsTitle[i].setChangeListener(this);
			add(newsTitle[i]);
			add(new SeparatorField());
		}
	}

 any help please

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: change listener problem

[ Edited ]

You may be confusing things here.

 

Field Listeners get invoked via the fieldChanged(..) method.

 

Individual fields (and Managers and Screens) use things like navigationClick and keyChar to react to actual input events.

 

So the normal process for your own Field is to have that Field override navigationClick, and then invoke fieldChangeNotify()  method.  This will then call the change listener. 

 

Does this make sense?  Is it what you are actually doing and I have just missed it?

 

Edit: Some typos fixed up.

Regular Contributor
Posts: 92
Registered: ‎01-31-2012
My Device: curve 8520
My Carrier: vodafone

Re: change listener problem

I implement it and fields don't respond Smiley Sad, even I use field change listener always (that's not my first time)but I don't know where's the problem this time
Regular Contributor
Posts: 92
Registered: ‎01-31-2012
My Device: curve 8520
My Carrier: vodafone

Re: change listener problem

now it worked with fieldChangeListener method but on 9800 simulator only
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: change listener problem

Can you give us a simple example, with just System.out.println(....) statements, which demonstrates the problem you are facing.  The code you have supplied above is confused because it does other things.  Let us just concentrate on a small bit of code that demonstrates the problem.  Show us the code, tell us the System.out.println statements that you see, and the ones you don't see that you expect to see.