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
Contributor
Posts: 20
Registered: ‎08-06-2011
My Device: Blackberry Torch 9800
My Carrier: Verizon

Blackberry navigation issue on clicking bitmap field

Hi,

 

      I have an issue to navigate on clicking button am using bitmap field as a button. The navigation takes place successfully when i push the next screen immediately in TouchEvent method. But I want to add some validation code before navigating to next screen. Am unable to do this. Can some one please suggest me how to do this?

 

                 I want my code something like below

 

            protectected boolean touchEvent(TouchEvent message)

            {

                      switch(TouchEvent.CLICK)

                      {

                               //validation code

                              // after validating push the next screen

                    }

           }

       please suggest me some ideas

Regards-

 

 

Developer
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000
My Carrier: airtel

Re: Blackberry navigation issue on clicking bitmap field

Hi Nivedita,

 

Try adding a if clause before navigation and in else try to navigate it to the next screen.

 

your code might be like this

 

protectected boolean touchEvent(TouchEvent message)

            {

                      switch(TouchEvent.CLICK)

                      {

                             If(){dialog.alert()}

else{pushscreen()}

                    }

           }

 

Let me know if it works fine.

 

Regards

Krishnan.

Developer
Posts: 102
Registered: ‎07-26-2011
My Device: Not a blackberry user
My Carrier: None

Re: Blackberry navigation issue on clicking bitmap field

[ Edited ]

Greetings.

 

That validation you are looking for may not be achieved within a switch statement, as you proposed.

 

Switch statements aren't useful while switching on constant values, and, unfortunately, you cannot switch on objects.

 

You could solve that using the if-then-else statements checking every type of TouchEvent separately, as follows:

 

protected boolean touchEvent(TouchEvent message) {
	if (message.getEvent() == TouchEvent.CLICK) {
		//validate
		//do desired stuff
	}
	else if (message.getEvent() == TouchEvent.DOWN) {
		//validate
		//do desired stuff
	}
	else {
		//do nothing or whatever
	}
	return super.touchEvent(message);
	//returns true in case you want to set this event as handled;
}

 

In case you need some help with the if-then-else statements, go to: IF-THEN-ELSE statements..

 

To know the constants in the TouchEvent class, go to: TouchEvent Reference API.

 

I hope this help. Good luck. 


Let me know if this was helpful or if you have a solution.

Johan Guzmán - In case my answer pleased you, give a press to the LIKE button, please!! Mark this post as solution if it solved your problem.
Contributor
Posts: 20
Registered: ‎08-06-2011
My Device: Blackberry Torch 9800
My Carrier: Verizon

Re: Blackberry navigation issue on clicking bitmap field

Hi,

 

         I have tried using IF-Else statments in the touchevent method but it is not working. Where as the same works if i use the button field. Am using Bitmap field as button. I want the validations on clicking the Bitmap field. Can Some One suggest me how I can achieve this

 

Regards-

Contributor
Posts: 20
Registered: ‎08-06-2011
My Device: Blackberry Torch 9800
My Carrier: Verizon

Re: Blackberry navigation issue on clicking bitmap field

Hi,

 

        Do I need to use x,y coordinates or how i can achieve this. Suggest me some ideas.

 

Regards-

Developer
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000
My Carrier: airtel

Re: Blackberry navigation issue on clicking bitmap field

Hi Nivedita

 

Can you post your code where you are using bitmap button field and where you are invoking it.

 

Regards

Krishnan

Contributor
Posts: 20
Registered: ‎08-06-2011
My Device: Blackberry Torch 9800
My Carrier: Verizon

Re: Blackberry navigation issue on clicking bitmap field

Hi,

 

 I have got the solution actually I was not getting the text properly from edit field that was the problem.

 

Regards-

Developer
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000
My Carrier: airtel

Re: Blackberry navigation issue on clicking bitmap field

please set this thread as solved..