Search This Blog

Thursday, 14 June 2012

How to get touchevent on any field in Blackberry.

Hello friends,
                     Here is something interesting , what if you wana use some icons in your app and want to do something on click like for simplicity change that icon on click it is a simple code...


Suppose we have a png image in res folder with the name 'abc.png'

So, first we initialize and declare a BitmapField...

Bitmap _icon = Bitmap.getBitmapResource("abc.png");
Bitmap _iconClick = Bitmap.getBitmapResource("abcClick.png");
BitmapField _icon1 = new BitmapField(_icon){
//Now we do something on Click on this BitmapField

public boolean touchEvent(TouchEvent message){
       //Do something on click here

       //Change the icon on Click
       return true;

return false;


  1. nice idea !! are you sure it will work??

    1. yes buddy, i always follow this strategy instead using buttons i use BitmapFiuelds and call their touchEvent method ....this way i can use anything as a button can also change the Bitmap on click to give it a perfect button effect.I am using a glow effect , whenever a user clicks the next bitmap is displayed with a glow ...that gives a nice effect

  2. and one thing more friend, you can try other features alos like hover,down,gesture etc....its fun to do different things on touch

  3. heyyy thanx..!! will ask you more but let me try this first.