Using createContainer() to load a existing container a row in a list

82 views
Skip to first unread message

Gareth Murfin

unread,
Nov 12, 2013, 10:32:07 AM11/12/13
to codenameone...@googlegroups.com
Using createContainer() to load a existing container a row in a list - when I do this the layout is all messed up, I cant even see the components on it, I really do not want to have to define my rows programatically as it takes a long time to make them look nice, if theyre complicated it can take all day.

So how do I use an existing container (or form???) made i n the gui builder as a row?

As a test im trying:

 public Container createRowContainer()
    {
         Container rowContainer = parentSM.createContainer(parentSM.resources, "myrow");
         return rowContainer;
    }


and this gets called in my list class:

 protected ListCellRenderer createListRenderer() {
       // MultiButton sel = createRendererMultiButton();
       // MultiButton unsel = createRendererMultiButton();
        
        Container sel = createRowContainer();
        Container unsel = createRowContainer();
        
        _("createListRenderer");
        _("sel:"+sel.getUIID());
        _("unsel:"+unsel.getUIID());
        return new GenericListCellRenderer(sel, unsel);
    }


Unfortunately it doesnt display correctly, this this actually possible? If so it would be lovely to see an example that works! Thanks!

Shai Almog

unread,
Nov 12, 2013, 2:12:49 PM11/12/13
to codenameone...@googlegroups.com
This should work just fine. I'm guessing the specific layout doesn't behave as you expect it to behave in the renderer context.

Gareth Murfin

unread,
Nov 14, 2013, 4:57:18 AM11/14/13
to codenameone...@googlegroups.com
it doesnt work correctly, "something" appears as a row but I dont see my labels or buttons etc, its highly distressing because now i m having to program complex guis by hand which is something I dont want to do !!! However I cant even find ONE example where rows are made from existing gui containers!! There must be one?? Otherwise I conclude that it has not been used/tested and has bugs :-(((((

Shai Almog

unread,
Nov 14, 2013, 1:44:29 PM11/14/13
to codenameone...@googlegroups.com
Just to be clear, what you are doing is hacking. We designed this to work via the GUI builder not the way you are doing this, although it should work in theory based on what I understand from your description (this is obviously limited since our communication protocol is naturally lossy).
This is what we do in UIBuilder.java to set the generic list cell renderer (notice that fisheye will be false):
    private GenericListCellRenderer readRendererer(Resources res, DataInputStream in) throws IOException {
       
int rendererComponentCount = in.readByte();
       
String f = in.readUTF();
       
String s = in.readUTF();
       
if(rendererComponentCount == 2) {
           
Component selected = createContainer(res, f);
           
Component unselected = createContainer(res, s);
           
GenericListCellRenderer g = new GenericListCellRenderer(selected, unselected);
            g
.setFisheye(!f.equals(s));
           
return g;
       
} else {
           
Component selected = createContainer(res, f);
           
Component unselected = createContainer(res, s);
           
Component even = createContainer(res, in.readUTF());
           
Component evenU = createContainer(res, in.readUTF());
           
GenericListCellRenderer g = new GenericListCellRenderer(selected, unselected, even, evenU);
            g
.setFisheye(!f.equals(s));
           
return g;
       
}
   
}


Gareth Murfin

unread,
Nov 14, 2013, 2:05:48 PM11/14/13
to codenameone...@googlegroups.com
Surely this is doing it via the gui builder? in what respect am I hacking this? 

Also, just to clarify all I am trying to achieve is to create rows from an existing container made in the gui builder. It seems they somehow get messed up . What is the fish eye thing, why is that there? maybe thats my issue?

Shai Almog

unread,
Nov 14, 2013, 2:20:47 PM11/14/13
to codenameone...@googlegroups.com
Fisheye is unreleated. If you are using the GUI builder just click renderer in the List itself and pick your container. That would work and that's what we test.

If you want to see what fisheye is then do that, its documented there and I spent a lot of time writing it there.

Gareth Murfin

unread,
Nov 14, 2013, 9:38:55 PM11/14/13
to codenameone...@googlegroups.com
Wow, I get it now! And this explains it all very well here https://www.youtube.com/watch?v=b9I-OjJRelk (took me way too long to find this hehe)

Thanks, now my lists will look awesome! Got my app going on iphone4s earlier, looks awesome, picking up a HTC Butterfly tomorrow for testing :-) - then the next pay day some sort of android tab probably- I think I will do a review of codenameone for my website once I finish this app and get some rest, overall I think it would be very positive given the time it has saved me, today I was able to demo my app to a client on ios/android at the same time, very impressive stuff :) 

I would also be interested in helping with the codenameone development if you are in need of any developers :) I would actually like the GUI to be editable in some sort of in-between language like XML, which would make styling things much easier, and copy and pasting stuff would be so fast and fluid, right now I find the styling issues a bit difficult etc.   

Today was all iOS apple / signing woes, but now I know i can wake up tomorrow and simply hit build :)..
Reply all
Reply to author
Forward
0 new messages