I am working on the following code which has a welcome form with 6 buttons.
On click of each of those buttons it opens a new form.
class MyAPP extends UiApplication {
public static void main(String[] args) {
UiApplication instance = new MyAPP();
instance.enterEventDispatcher();
}
private ButtonField btntest,btntest1,btntest2,btntest3,btntest4,btntest5;
public MyAPP() {
MainScreen testScreen = new MainScreen();
final LabelField field = new LabelField("Company",LabelField.FIELD_HCENTER | LabelField.NON_FOCUSABLE)
{
protected void paint(Graphics g)
{
g.clear();
g.drawRect(0,0, 50, 50);
int oldColor = g.getColor();
g.setColor(Color.DODGERBLUE);
g.fillRect(0, 0, this.getPreferredWidth(), this.getPreferredHeight());
g.setColor(oldColor);
g.drawRect(100, 100, 50, 50);
super.paint(g);
}
};
testScreen.setTitle(field);
//Add status field to bottom of screen in blue color
final LabelField field1 = new LabelField(" Copyright")
{
protected void paint(Graphics g)
{
// g.clear();
g.drawRect(0,0, 50, 50);
int oldColor = g.getColor();
g.setColor(Color.DODGERBLUE);
g.fillRect(0, 0, this.getPreferredWidth(), this.getPreferredHeight());
g.setColor(oldColor);
g.drawRect(100, 100, 50, 50);
super.paint(g);
}
};
//field1.setFontColor(Color.WHITE);
btntest1 = new ButtonField("Customer",ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
btntest = new ButtonField("Bills ",ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
btntest2 = new ButtonField("Ledger ",ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
btntest3 = new ButtonField("Receipts",ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
btntest1.setChangeListener(new FieldChangeListener()
{
public void fieldChanged(Field field,int context)
{
pushScreen(new NextScreen2());
}
});
btntest.setChangeListener(new FieldChangeListener()
{
public void fieldChanged(Field field,int context)
{
pushScreen(new NextScreen1());
}
});
btntest2.setChangeListener(new FieldChangeListener()
{
public void fieldChanged(Field field,int context)
{
pushScreen(new NextScreen4());
}
});
I have also tried putting an image bitmap that lies on the center of the form but it doesnt appear anywhere.
In the present code i have added title and status fields and also i have added
Is it because the buttons are in center and there is no space left for the color implementation to take place that it is not visible?Also i am unable to add an image that stays as a background to the entire form.Anyone aware on a solution please guide.Thanks
Try following code:
// initialize background
Bitmap bm = Bitmap.getBitmapResource("myImage");
Background bg = BackgroundFactory.createBitmapBackground(bm);
// getMainManager(), apply background
testScreen.getMainManager().setBackground(bg);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.