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
New Contributor
Posts: 2
Registered: ‎03-04-2011
My Device: Not Specified

Image Button

package com.beginningblackberry.uifun;

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.system.EncodedImage;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;

import net.rim.device.api.ui.container.*;



public class LoginSucessScreen extends MainScreen {
  
    EncodedImage ei = EncodedImage.getEncodedImageResource("home.png");
    BitmapField bmp = new BitmapField(ei.getBitmap(),BitmapField.FOCUSABLE| DrawStyle.HCENTER);
    public LoginSucessScreen()
    {
        final LabelField title = new LabelField("Images",
                LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);

    setTitle(title);
        HorizontalFieldManager horizontalFieldManager = new
        HorizontalFieldManager(NO_VERTICAL_SCROLL);
           

        VerticalFieldManager horizontalFieldManager1 = new
        VerticalFieldManager(Field.FIELD_HCENTER);
       
    //add(horizontalFieldManager);
    FocusChangeListener listener = new FocusChangeListener(){
        public void focusChanged(Field field, int eventType)
        {
            if (eventType == FOCUS_CHANGED) {
        UiApplication.getUiApplication().pushScreen(new FinalScreen());
            }
        }
    };
    horizontalFieldManager1.add(bmp);
    bmp.setFocusListener(listener);
    horizontalFieldManager.add(horizontalFieldManager1);
    add(horizontalFieldManager);
        // TODO Auto-generated constructor stub       
    }
    
    


    public LoginSucessScreen(long style) {
        super(style);
        // TODO Auto-generated constructor stub
    }

    /**
     * @param args
     */
}

 

 

this is code inwhich i am trying to open new screen when i click on image. but i can't click on image.

help me for this problem.. i want to focusable to my image and want to fire click event in image.

Contributor
Posts: 20
Registered: ‎05-21-2012
My Device: NA
My Carrier: NA

Re: Storm 9500 - Image Button

How to convert button to image button

 

 

public static String BTN_PREV ="Previous";   /////////////////This is a previous button

 

i want in the place of "previous" use image (.png image).

 

next code here......

 

btnPrev = new EmbossedButtonField(MessageConstant.BTN_PREV, ButtonField.CONSUME_CLICK);
btnPrev.setMargin(0, 0, 0, prt);

 

 

how to solve this?

 

Highlighted
Contributor
Posts: 20
Registered: ‎05-21-2012
My Device: NA
My Carrier: NA

Re: Storm 9500 - Image Button

How to convert button to image button





public static String BTN_PREV ="Previous"; /////////////////This is a previous button



i want in the place of "previous" use image (.png image).



next code here......



btnPrev = new EmbossedButtonField(MessageConstant.BTN_PREV, ButtonField.CONSUME_CLICK);
btnPrev.setMargin(0, 0, 0, prt);





how to solve this?