List of all Iphone and Blackberry Development codes in a one click Iphone,objective C,xcode,blackberry Development,iOS Development

Friday, April 27, 2012

Image Zoom In and Zoom Out in Blackberry

The following code will give you the functionality like- Zoom in and out.

    public final class ZoomScreenDemo extends UiApplication
{
   public static void main(final String[] args)
   {
       // Create a new instance of the application and make the currently
       // running thread the application's event dispatch thread.
       UiApplication app = new ZoomScreenDemo();
       app.enterEventDispatcher();
   }


/**
* Creates a new ZoomScreenDemo object
*/
public ZoomScreenDemo()
{
   UiApplication.getUiApplication().invokeLater(new Runnable()
   {
       public void run()
       {
           Dialog.alert("Click trackball or screen to zoom");
       }
   });

   pushScreen(new ZoomScreenDemoScreen());
}


public final static class ZoomScreenDemoScreen extends MainScreen
{  
   private EncodedImage _image;      

   /**
    * Creates a new ZoomScreenDemoScreen object
    */
   public ZoomScreenDemoScreen()
   {        
       setTitle("Zoom Screen Demo");        

       _image = EncodedImage.getEncodedImageResource("img/building.jpg");      
       BitmapField bitmapField = new BitmapField(_image.getBitmap(), FIELD_HCENTER | FOCUSABLE);
       add(bitmapField);          
   }    


  /**
   * @see Screen#navigationClick(int, int)
   */
   protected boolean navigationClick(int status, int time)
   {
       // Push a new ZoomScreen if track ball or screen is clicked
       UiApplication.getUiApplication().pushScreen(new ZoomScreen(_image));                          
       return true;
   }


   /**
   * @see Screen#touchEvent(TouchEvent)
   */
   protected boolean touchEvent(TouchEvent message)
   {  
       if(message.getEvent() == TouchEvent.CLICK)
       {
           UiApplication.getUiApplication().pushScreen(new ZoomScreen(_image));                          
       }
       return super.touchEvent(message);        
   }
}
}





        

No comments:

Post a Comment