BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 02-24-2010, 01:22 PM   #1 (permalink)
New Member
 
Join Date: Feb 2010
Model: Storm
PIN: N/A
Carrier: AT&T
Posts: 8
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default fieldchangenotify() ??

Please Login to Remove!

Hi..


Please explain the the fieldchangenotify(int context) function...

what does this function actually do and when it is used and whats the concept of context here ??


Thanx
Offline  
Old 03-11-2010, 06:25 PM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2010
Model: N/A
PIN: N/A
Carrier: Fledge
Posts: 43
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi bb_develop,

FieldChangeNotify is used in conjunction with the FieldChangeListener interface to handle events. The most common scenario is that you want to perform an action when a user clicks on a button. The "context" parameter is completely arbitrary - for example, you may want to send a different context integer if the user clicks via the navigation wheel, or with the "enter" key.

For example, take a look at the following code (which I haven't really tested, but the concepts are certainly correct):
Code:
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;

public class TestClass extends MainScreen implements FieldChangeListener {
	LabelField labelField;
	public TestClass() {
		labelField = new LabelField("Click here to see a dialog", Field.FOCUSABLE) {
			protected boolean navigationClick(int status, int time) {
				fieldChangeNotify(0);
				return true;
			}			
			protected boolean keyChar(char character, int status, int time) {
				if (character == Keypad.KEY_ENTER) {
					fieldChangeNotify(1);
					return true;
				}
				return super.keyChar(character, status, time);
			}
		};

		labelField.setChangeListener(this);
		add(labelField);
	}
	public void fieldChanged(Field field, int context) {
		if (field == labelField) {
			if (context == 0) Dialog.alert("You clicked on the field!");
			if (context == 1) Dialog.alert("You pressed the enter key!");
		}
	}
}

Last edited by jacob.tabak : 03-11-2010 at 06:26 PM. Reason: Forgot code tags
Offline  
Closed Thread


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

MSA Altair H2S Single Gas Detector (11 Months Remaining)
$49.95
MSA Altair H2S Single Gas Detector (11 Months Remaining) pictureMSA Altair 4X, Good Condition, Calibrated
$329.99
MSA Altair 4X, Good Condition, Calibrated pictureMSA Altair 5X, Calibrated, Accessories, Warranty
$759.99
MSA Altair 5X, Calibrated, Accessories, Warranty pictureMSA Altair 5X with Color Screen, Calibrated, Accessories
$769.99
MSA Altair 5X with Color Screen, Calibrated, Accessories pictureMSA Altair 5, Color Screen, Calibrated, Accessories
$439.99
MSA Altair 5, Color Screen, Calibrated, Accessories picture






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