Я хочу создать шесть кнопок с изображениями, похожих на те, что на главном экране, например настройки, загрузки или сообщения. Когда я перехожу к следующей кнопке, предыдущая должна исчезнуть, как и в симуляторе. Я использую симулятор 9700 и JDE 5.0.0.
Кнопки изображения BlackBerry
comment
Дубликат кнопки stackoverflow.com/questions/2912223/image-button-in- ежевика
- person Michael Donohue   schedule 23.10.2010
comment
проверьте эту ссылку Нажмите меня
- person rupesh   schedule 25.10.2010
comment
попробуйте переопределить метод onFocus () ...
- person BBdev   schedule 06.10.2011
comment
вам нужно создать настраиваемые поля кнопок и добавить их в качестве статуса экрана.
- person Arun Kumar Munusamy   schedule 07.10.2011
Ответы (1)
используйте этот класс, чтобы создать кнопку с настраиваемым изображением и добавить на экран:
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.ButtonField;
public class BitmapButtonField extends ButtonField {
private Bitmap bitmap;
private Bitmap bitmapHighlight;
private boolean highlighted = false;
/**
* Instantiates a new bitmap button field.
*
* @param bitmap the bitmap to use as a label
*/
public BitmapButtonField(Bitmap bitmap, Bitmap bitmapHighlight) {
this(bitmap, bitmapHighlight, ButtonField.CONSUME_CLICK|ButtonField.FIELD_HCENTER|ButtonField.FIELD_VCENTER);
}
public BitmapButtonField(Bitmap bitmap, Bitmap bitmapHighlight, long style) {
super(style);
this.bitmap = bitmap;
this.bitmapHighlight = bitmapHighlight;
}
/* (non-Javadoc)
* @see net.rim.device.api.ui.component.ButtonField#layout(int, int)
*/
protected void layout(int width, int height) {
setExtent(getPreferredWidth(), getPreferredHeight());
}
/* (non-Javadoc)
* @see net.rim.device.api.ui.component.ButtonField#getPreferredWidth()
*/
public int getPreferredWidth() {
return bitmap.getWidth();
}
/* (non-Javadoc)
* @see net.rim.device.api.ui.component.ButtonField#getPreferredHeight()
*/
public int getPreferredHeight() {
return bitmap.getHeight();
}
/* (non-Javadoc)
* @see net.rim.device.api.ui.component.ButtonField#paint(net.rim.device.api.ui.Graphics)
*/
protected void paint(Graphics graphics) {
super.paint(graphics);
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Bitmap b = bitmap;
if (highlighted)
b = bitmapHighlight;
graphics.drawBitmap(0, 0, width, height, b, 0, 0);
}
public void setHighlight(boolean highlight)
{
this.highlighted = highlight;
}
}
person
Appoorva Faldu
schedule
18.09.2013