0
votes

I am facing issue while displaying multiple columns in a row. I need multiple columns and multiple row list field. Now I am trying to make this using label field i one of my case its working quite good but in another case I am facing an issue please help me out. My code is:

VerticalFieldManager TOrderVFM = new VerticalFieldManager()

for ( int i = 0; i <10; i++)
{
    HorizontalFieldManager temphfm1 = new HorizontalFieldManager(){

        protected void sublayout(int width, int height)
        {

            int w = 480;
            int h = 400;

            super.sublayout(w, h);
            super.setExtent(w, h);
        }
    };

    TOrderVFM.add(temphfm1);

    temphfm1.add(createDayName1(MTradeOrderSoap.objects[i].getProperty("orderDate").toString()));
    temphfm1.add(createDayName1(MTradeOrderSoap.objects[i].getProperty("id").toString()));
    temphfm1.add(.createDayName1(MTradeOrderSoap.objects[i].getProperty("label").toString()));
    temphfm1.add(createDayName1(MTradeOrderSoap.objects[i].getProperty("quantityPending").toString()));
    temphfm1.add(createDayName1(MTradeOrderSoap.objects[i].getProperty("securityName").toString()));
    temphfm1.add(createDayName1(MTradeOrderSoap.objects[i].getProperty("priceType").toString()));
    temphfm1.add(createDayName1(MTradeOrderSoap.objects[i].getProperty("orderOrigin").toString()));

    temphfm1.add(ut.createDayName1(MTradeOrderSoap.objects[i].getProperty("orderStatus").toString()));

}   

This loop is inserting values that are coming from the soap response and passing it to the method named createDayName() which is also given below.Now this all works good for my one of the screens but when i try to follow this for my another screen i am facing an error:-WARNING: Cannot layout field, insufficient height or width

I have set the width and height of both the managers but nothing seems to be working .Please provide me a support to do that.

public LabelField createDayName1(final String day)
 {
    LabelField cell = new LabelField("", Field.NON_FOCUSABLE) {
        protected void layout(int width, int height)
        {
            int w = Display.getWidth()/7;
            int h = 40;
            super.layout(w, h);
            super.setExtent(w, h);
        }

        protected void paint(Graphics g)
        {
            g.setColor(0xFF9912);
            g.setFont(dayNameFont);
            g.fillRect(0, 0, getWidth(), getHeight());
            g.setColor(Color.BLACK);
            // g.setColor(0x466385);
            g.drawText(day.trim(), getWidth() / 2 - dayNameFont.getAdvance(day) / 3, getHeight() / 3 - dayNameFont.getHeight() / 2);
            super.paint(g);
        }

    };
    return cell;
}                                              
1

1 Answers

1
votes

In layout() and sublayout() you need to make sure you're comparing the width and height you are passing to setExtent() (and super.layout()/super.sublayout() for that matter) to the arguments getting sent to those methods because they are the maximum available width and height. If you try to tell the Field to be wider or taller (using setExtent()) than what is available, it won't be able to display properly.