BlackBerry Forums Support Community

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

Please Login to Remove!


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 ??

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

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):
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) {
				return true;
			protected boolean keyChar(char character, int status, int time) {
				if (character == Keypad.KEY_ENTER) {
					return true;
				return super.keyChar(character, status, time);

	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 05:26 PM. Reason: Forgot code tags

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