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
korizohaib
Posts: 8
Registered: ‎01-21-2014
My Device: 9800

display new screen when a image is clicked

public class MyScreen extends MainScreen {

public LanguageSelector() {

Bitmap logoBitmap = Bitmap.getBitmapResource("normalarabflag.png");
BitmapField bitmapField = new BitmapField(logoBitmap,Field.FIELD_HCENTER);
LabelField labelfield = new LabelField("Arabic ",Field.FIELD_HCENTER);
//
VerticalFieldManager vrt=new VerticalFieldManager(USE_ALL_WIDTH)
{
protected void sublayout(int maxWidth, int maxHeight) {

super.sublayout(Display.getWidth(),Display.getHeight());
setExtent(Display.getWidth(),Display.getHeight());
}
};
Font f=labelfield.getFont();
int hight1=f.getAdvance(labelfield.getText());
int k=labelfield.getPreferredHeight();

int number=hight1/Display.getWidth()+1;
int hight2=logoBitmap.getHeight();
int padding=(Display.getHeight()-((number*k)+hight2))/2;
if(padding>0){
bitmapField.setPadding(padding,0,0,0);
}

vrt.add(bitmapField);
vrt.add(labelfield);

add(vrt);

 

}

}

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: display new screen when a image is clicked

Sorry - your question is?

 

Can you describe in detail what you are trying to do with the BitmapFIelds?

 

Have you looked at 'navigationClick' method, which will be fired even on BitmapFields when the user is focused on the Field and presses the trackpad or taps on the icon when using a touchscreen?

New Contributor
korizohaib
Posts: 8
Registered: ‎01-21-2014
My Device: 9800

Re: display new screen when a image is clicked

i want to work on image using OnClickListener if any one click on image Action perform and this action push you on next screen

 

but thanks to reply i All ready done tha like this 

 

public class MyScreen extends MainScreen {

public MyScreen() {


Bitmap logoBitmap = Bitmap.getBitmapResource("normalarabflag.png");

BitmapField LogoBmpField = new BitmapField(logoBitmap, BitmapField.FOCUSABLE | Field.FIELD_HCENTER) {
protected boolean trackwheelClick(int status, int time) {
System.out.println(" -- You clicked me! ");
UiApplication.getUiApplication().pushScreen(new testerror());
Dialog.alert("Load Complete");
return true;
}
};

LabelField labelfield = new LabelField("Arabic ",Field.FIELD_HCENTER|LabelField.FOCUSABLE);

VerticalFieldManager vrt=new VerticalFieldManager(USE_ALL_WIDTH)
{
protected void sublayout(int maxWidth, int maxHeight) {

super.sublayout(Display.getWidth(),Display.getHeight());
setExtent(Display.getWidth(),Display.getHeight());
}
};
Font f=labelfield.getFont();
int hight1=f.getAdvance(labelfield.getText());
int k=labelfield.getPreferredHeight();

int number=hight1/Display.getWidth()+1;
int hight2=logoBitmap.getHeight();
int padding=(Display.getHeight()-((number*k)+hight2))/2;
if(padding>0){
LogoBmpField.setPadding(padding,0,0,0);
}

vrt.add(LogoBmpField);
vrt.add(labelfield);

add(vrt);

}

}

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: display new screen when a image is clicked

Try navigationClick() rather than trackwheelClick,  Trackwheels were used in old devices.