online image on list

289 views
Skip to first unread message

shyam tha

unread,
Aug 5, 2014, 5:52:54 AM8/5/14
to codenameone...@googlegroups.com

I am using above list renderer in my list it only shows loading.png image . 
The loading image should be replaced by online image which is stored in storage but it is not displaying .
But when I restart , it displays new images from storage how to solve it ? 


/*

/**
 *
 * @author Shyam
 */
public class SimpleCellRenderer  implements ListCellRenderer {

    private Container content;
    Container mainContainer;
    private Label titleLable;
    private Label imageLable;

    private Label focus = new Label();

    public SimpleCellRenderer() {
        try {

            Resources resources = Resources.openLayered("/theme");
            UIBuilder uIBuilder = new UIBuilder();
            mainContainer = uIBuilder.createContainer(resources, "RowContainer2");

            content = (Container) uIBuilder.findByName("Container3", mainContainer);

            titleLable = (Label) uIBuilder.findByName("Itemtitle", mainContainer);
            imageLable = (Label) uIBuilder.findByName("ImagePath", mainContainer);



        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    synchronized public Component getListCellRendererComponent(List list, Object value,
            int index, boolean isSelected) {

        if (mainContainer != null) {
            Hashtable v = (Hashtable) value;
            if (v != null) {
                try {

                    String name = (String) v.get("name");
                    String url = (String) v.get("ImagePath");
                    boolean isImageFound = Storage.getInstance().exists(name);
                    Log.p(" is image found " + index + " " + isImageFound);
                    if (isImageFound) {
                        addStorageImage(name);
                    } else {
                        addOnlineImage(url, name);
                    }


                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {

            }
        }
     
        return mainContainer;
    }

    public Component getListFocusComponent(List list) {
        return focus;
    }

    synchronized void addOnlineImage(String url, String name) {

        Log.p(" image url " + url);
        Log.p(" name  " + name);
        try {

            Resources res = Resources.openLayered("/theme");
            Image image = res.getImage("loading.png");

            EncodedImage encodedImage = EncodedImage.createFromImage(image, true);
            Image urlImag = URLImage.createToStorage(encodedImage, name, url, URLImage.RESIZE_SCALE_TO_FILL);
            imageLable.setText("online");
            imageLable.setIcon(urlImag);

        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    synchronized void addStorageImage(String name) {
//        Log.p(" add storage image ");
        try {
            InputStream stream = Storage.getInstance().createInputStream(name);
//            InputStream stream = FileSystemStorage.getInstance().openInputStream(name);
            Image storageImage = Image.createImage(stream);
            imageLable.setIcon(storageImage);

            imageLable.setText("storage");

        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}



If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator
Device

Shai Almog

unread,
Aug 5, 2014, 9:37:01 AM8/5/14
to codenameone...@googlegroups.com
This won't work.
URLImage was meant to work with the GenericListCellRenderer which will automatically repaint the list as needed, this is pretty complex stuff if you don't use the GUI builder or the generic list cell renderer.

shyam tha

unread,
Aug 5, 2014, 10:38:43 PM8/5/14
to codenameone...@googlegroups.com
I have desined Row with GUI DESIGNER named Container2 and call it in renderer by using following code


            Resources resources = Resources.openLayered("/theme");
            UIBuilder uIBuilder = new UIBuilder();
            mainContainer = uIBuilder.createContainer(resources, "RowContainer2");

All text are displayed but downloaded image is not repainting why ?
And again when I restart the app , the downloaded images are displayed so how to solve it?

Shai Almog

unread,
Aug 6, 2014, 2:16:33 AM8/6/14
to codenameone...@googlegroups.com
How did you set the downloaded image value?

shyam tha

unread,
Aug 6, 2014, 2:55:11 AM8/6/14
to codenameone...@googlegroups.com
  getListCellRendererComponent(..................){

 addOnlineImage
}



synchronized void addOnlineImage(String url, String name) {

        Log.p(" image url " + url);
        Log.p(" name  " + name);
        try {

            Resources res = Resources.openLayered("/theme");
            Image image = res.getImage("loading.png");

            EncodedImage encodedImage = EncodedImage.createFromImage(image, true);
            Image urlImag = URLImage.createToStorage(encodedImage, name, url, URLImage.RESIZE_SCALE_TO_FILL);
            imageLable.setText("online");
            imageLable.setIcon(urlImag);

        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
On Wed, Aug 6, 2014 at 12:01 PM, Shai Almog <shai....@gmail.com> wrote:
How did you set the downloaded image value?

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/ostXxPKQzRU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/8051a9ed-1a03-4672-89aa-64e083bcba66%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Shai Almog

unread,
Aug 6, 2014, 10:34:08 AM8/6/14
to codenameone...@googlegroups.com
That's unrelated to generic list cell renderer. I'm assuming you misused it.
You need to use component names with model data to indicate the URL to fetch the image from. You don't need to use the URLImage class for that.

shyam tha

unread,
Aug 7, 2014, 12:28:10 AM8/7/14
to codenameone...@googlegroups.com
   on getItemAt method of Model

  public Object getItemAt(int index) { 
...................................
  Hashtable hashtable= new Hashtable();
      hashtable.put("ImagePath", url);
 ..........................
}

imagePath is name of label in which I want to put the image 
And which class should be used instead of URLImage ?

And list is being very slow what should be done for that ?

shyam tha

unread,
Aug 7, 2014, 2:14:06 AM8/7/14
to codenameone...@googlegroups.com
I have also use the following instead of URLImage to display image in label named ImageLabel but still unsuccess.           

 Image image = res.getImage("setting.png");
        EncodedImage encodedImage = EncodedImage.createFromImage(image, true);
        imageLable.setText("");
        ImageDownloadService.createImageToStorage(url, list, index + 1, imageLable.getName(), name, encodedImage, ConnectionRequest.PRIORITY_HIGH);

how can I solve it? 

Shai Almog

unread,
Aug 7, 2014, 1:22:19 PM8/7/14
to codenameone...@googlegroups.com
See the last paragraph about lists: http://www.codenameone.com/blog/image-from-url-made-easy
Make sure you are using the GenericListCellRenderer and not your existing renderer which won't work with that.

shyam tha

unread,
Aug 13, 2014, 7:57:16 AM8/13/14
to codenameone...@googlegroups.com
I have gone via above link and still online image is not working.
 
Resources res = Resources.openLayered("/theme");
 Image image = res.getImage("img-not-found.png");
 EncodedImage encodedImage = EncodedImage.createFromImage(image, true);         
 entry.put("ImagePath",encodedImage);
I have used above codes in listmodel which displays images in item of list and similiar how can I display image from url 
I will glad if you provides few lines of codes related it .

Shai Almog

unread,
Aug 13, 2014, 10:54:48 AM8/13/14
to codenameone...@googlegroups.com
Look at the Kitchen Sink demo where we use the GenericListCellRenderer in the contacts demo.
Use that approach. Alternatively use the GUI builder with the generic list cell rendererer.

shyam tha

unread,
Aug 13, 2014, 9:29:46 PM8/13/14
to codenameone...@googlegroups.com
Thank shai for your suggestion 
I am able to display dynamic data from online json files into list
and my problem is online image is not displaying in list 
I have follow this link also
and still having problem so please guide me steps by steps to display online image in list with codes

Shai Almog

unread,
Aug 14, 2014, 2:43:35 AM8/14/14
to codenameone...@googlegroups.com
The first step is to use a generic list cell renderer and not your custom renederer.
The second step is to place the URL for the image in the model under something like icon_URLImage.
Step three profit.
Message has been deleted

shyam tha

unread,
Aug 14, 2014, 3:32:04 AM8/14/14
to codenameone...@googlegroups.com
 private Container createGRContainer() {
        Container mainContainer = (Container) createContainer("/theme", "RowContainer2");
    return  mainContainer;
}

I have followed both steps in list which is mentioned below and please points out where is my mistake.

1.   items.setRenderer(new GenericListCellRenderer(createGRContainer(), createGRContainer()));

2.  a. hashtable.put("ImagePath", url); (which displays the url in label)
        so try next this one
     b. hashtable.put("icon_ImagePath", url); (which displays no things)
     c. Resources res = Resources.openLayered("/theme");
          Image image = res.getImage("img-not-found.png");
          EncodedImage encodedImage = EncodedImage.createFromImage(image, true);         
          hashtable.put("ImagePath",encodedImage); 
         (which shows image from resource but I want to show image from url , how to do that)

Shai Almog

unread,
Aug 14, 2014, 1:05:32 PM8/14/14
to codenameone...@googlegroups.com
Where did you get icon_ImagePath from.
Use icon_URLImage

shyam tha

unread,
Aug 14, 2014, 11:43:21 PM8/14/14
to codenameone...@googlegroups.com
when rename name of ImagePath to shyam_URLImage 
and hashtable.put(" icon_URLImage", imageUrl);

it shows followings error how to solve it?

java.lang.NullPointerException
at com.codename1.ui.list.GenericListCellRenderer.updateModelValues(GenericListCellRenderer.java:400)
at com.codename1.ui.list.GenericListCellRenderer.getCellRendererComponent(GenericListCellRenderer.java:362)
at com.codename1.ui.list.GenericListCellRenderer.getListCellRendererComponent(GenericListCellRenderer.java:415)
at com.codename1.ui.plaf.DefaultLookAndFeel.getListPreferredSizeImpl(DefaultLookAndFeel.java:777)
at com.codename1.ui.plaf.DefaultLookAndFeel.getListPreferredSize(DefaultLookAndFeel.java:731)
at com.codename1.ui.List.calcPreferredSize(List.java:2035)
at com.codename1.ui.Component.preferredSizeImpl(Component.java:1824)
at com.codename1.ui.Component.preferredSize(Component.java:1859)
at com.codename1.ui.Component.getPreferredSize(Component.java:715)
at com.codename1.ui.Component.getPreferredH(Component.java:805)
at com.codename1.ui.layouts.BoxLayout.getPreferredSize(BoxLayout.java:170)
at com.codename1.ui.Container.calcPreferredSize(Container.java:1451)
at com.codename1.ui.Component.calcScrollSize(Component.java:745)
at com.codename1.ui.Component.getScrollDimension(Component.java:732)
at com.codename1.ui.Container.isScrollableY(Container.java:1526)
at com.codename1.ui.Component.isScrollable(Component.java:1599)
at com.codename1.ui.Form.isScrollable(Form.java:2850)
at com.codename1.ui.Component.checkAnimation(Component.java:3179)
at com.codename1.ui.Component.initComponentImpl(Component.java:3563)
at com.codename1.ui.Container.initComponentImpl(Container.java:700)
at com.codename1.ui.Form.initComponentImpl(Form.java:1402)
at com.codename1.ui.Display.setCurrent(Display.java:1259)
at com.codename1.ui.Form.show(Form.java:1383)
at com.codename1.ui.Form.show(Form.java:1361)
at com.codename1.ui.util.UIBuilder.showForm(UIBuilder.java:2437)
at com.codename1.ui.util.UIBuilder.showContainerImpl(UIBuilder.java:2325)
at com.codename1.ui.util.UIBuilder.showContainer(UIBuilder.java:2205)
at com.codename1.ui.util.UIBuilder$FormListener.actionPerformed(UIBuilder.java:2824)
at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:345)
at com.codename1.ui.Form.actionCommandImplNoRecurseComponent(Form.java:1337)
at com.codename1.ui.Button.fireActionEvent(Button.java:389)
at com.codename1.ui.Button.released(Button.java:424)
at com.codename1.ui.Button.pointerReleased(Button.java:512)
at com.codename1.ui.Form.pointerReleased(Form.java:2365)
at com.codename1.ui.Form.pointerReleased(Form.java:2301)
at com.codename1.ui.Component.pointerReleased(Component.java:2596)
at com.codename1.ui.Display.handleEvent(Display.java:1897)
at com.codename1.ui.Display.edtLoopImpl(Display.java:999)
at com.codename1.ui.Display.mainEDTLoop(Display.java:930)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)

Shai Almog

unread,
Aug 15, 2014, 12:16:43 AM8/15/14
to codenameone...@googlegroups.com
You also need to define iconName which will indicate the name with which the image will be cached in storage.

shyam tha

unread,
Aug 15, 2014, 12:42:08 AM8/15/14
to codenameone...@googlegroups.com
I have used following code in model 
 
entry.put("iconName", name);
 entry.put("icon_URLImage",imageUrl);
And 
Duplicate entry detected error is displayed how to solve this problems 
I have noticed that getItemAt method of listmodel is calling multiple times how to solve that ?

Shai Almog

unread,
Aug 15, 2014, 10:51:58 AM8/15/14
to codenameone...@googlegroups.com
Get item at is invoked VERY frequently, its not a problem you need to code with that in mind.
The duplicate entry will happen if all URL's are the same.

shyam tha

unread,
Aug 15, 2014, 11:32:21 AM8/15/14
to codenameone...@googlegroups.com

Which conditions be checked to remove frequently calling?

On Aug 15, 2014 8:36 PM, "Shai Almog" <shai....@gmail.com> wrote:
Get item at is invoked VERY frequently, its not a problem you need to code with that in mind.
The duplicate entry will happen if all URL's are the same.

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/ostXxPKQzRU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.

Shai Almog

unread,
Aug 16, 2014, 3:30:17 AM8/16/14
to codenameone...@googlegroups.com
It will be called frequently, you need to optimize your code with that in mind.

shyam tha

unread,
Aug 16, 2014, 4:42:11 AM8/16/14
to codenameone...@googlegroups.com
can you give me some clue for it ?

Shai Almog

unread,
Aug 16, 2014, 10:13:49 AM8/16/14
to codenameone...@googlegroups.com
I don't understand what sort of "clue" you need for something that is a fact that you can't change. Renderer will be invoke a lot since it needs to animate elements into place.

shyam tha

unread,
Aug 17, 2014, 4:03:07 PM8/17/14
to codenameone...@googlegroups.com

I am using following listModel



public class ListModel1 implements ListModel {


    private int selected;

    private EventDispatcher selectionListeners = new EventDispatcher();

    private int no;

    private ArrayList<ItemModel> itemModels;

    List list;


    public ListModel1(ArrayList<ItemModel> itemModels, List list) {

        this.list = list;

        this.no = itemModels.size();

        this.itemModels = itemModels;

    }


    public Object getItemAt(int index) {

        

  

        

            Resources res = Resources.openLayered("/theme");

            Image image = res.getImage("setting.png");        

            ItemModel itemModel = itemModels.get(index);


            String name = new ImageUrl().getImageName(itemModel.getImageUrl());


            boolean isImageFound = Storage.getInstance().exists(name);

            entry.put("id", "" + itemModel.getId());


            entry.put("iconk_URLImage", itemModel.getImageUrl());


        return entry;

    }


    public int getSize() {

        return no;

    }


    public int getSelectedIndex() {

        return selected;

    }


    public void setSelectedIndex(int index) {

        if (this.selected != index) {

            int oldSelected = this.selected;

            this.selected = index;

            selectionListeners.fireSelectionEvent(oldSelected, selected);

        }

    }


    public void addDataChangedListener(DataChangedListener l) {

        // useful if we change the content of the list

    }


    public void removeDataChangedListener(DataChangedListener l) {

    }


    public void addSelectionListener(SelectionListener l) {

        selectionListeners.addListener(l);

        Log.p(" add selection listner ");


    }


    public void removeSelectionListener(SelectionListener l) {

        selectionListeners.removeListener(l);

    }


    public void addItem(Object item) {

    }


    public void removeItem(int index) {

    }


    

}

And following RendererContainer 

 private Container createGenericRendererContainer() {
        Container c = new Container(new BorderLayout());
        try {
        
            Image image =fetchResourceFile().getImage("setting.png");
            
            c.setUIID("ListRenderer");
            Label name = new Label();
            name.setIcon(image);

            name.setName("iconk_URLImage");
            c.addComponent(BorderLayout.CENTER, name);
            Label surname = new Label();
            surname.setFocusable(true);
            surname.setName("id");
            c.addComponent(BorderLayout.SOUTH, surname);
                
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        return c;
    }


And getItemAt method is called repeatedly 
and the online image is not still displayed ?
how display online image and handle getItemAt method call?

shyam tha

unread,
Aug 17, 2014, 4:10:29 PM8/17/14
to codenameone...@googlegroups.com

I am using following listModel



public class ListModel1 implements ListModel {


    private int selected;

    private EventDispatcher selectionListeners = new EventDispatcher();

    private int no;

    private ArrayList<ItemModel> itemModels;

    List list;


    public ListModel1(ArrayList<ItemModel> itemModels, List list) {

        this.list = list;

        this.no = itemModels.size();

        this.itemModels = itemModels;

    }


    public Object getItemAt(int index) {

        

  

        

            Resources res = Resources.openLayered("/theme");

            Image image = res.getImage("setting.png");        

Message has been deleted

shyam tha

unread,
Aug 17, 2014, 10:38:41 PM8/17/14
to codenameone...@googlegroups.com

I am using following listModel



public class ListModel1 implements ListModel {


    private int selected;

    private EventDispatcher selectionListeners = new EventDispatcher();

    private int no;

    private ArrayList<ItemModel> itemModels;

    List list;


    public ListModel1(ArrayList<ItemModel> itemModels, List list) {

        this.list = list;

        this.no = itemModels.size();

        this.itemModels = itemModels;

    }


    public Object getItemAt(int index) {

        

  

        

            Resources res = Resources.openLayered("/theme");

            Image image = res.getImage("setting.png");        

how to display online image and to  handle getItemAt method for multiple calling ?

shyam tha

unread,
Aug 17, 2014, 10:47:31 PM8/17/14
to codenameone...@googlegroups.com

I am using attached listmodel and rendererContainter in  project .

  I am still facing below problems 

1. getItemAt method is called repeatedly 

2.and the online image is not still displayed ?

how to display online image and to handle getItemAt method call ?

RendererContainerMethod.txt
ListModel1.java

Shai Almog

unread,
Aug 18, 2014, 1:56:11 AM8/18/14
to codenameone...@googlegroups.com
Get item will be invoked a lot which is exactly the point.
What values are in the model.

shyam tha

unread,
Aug 18, 2014, 2:09:41 AM8/18/14
to codenameone...@googlegroups.com
 I am only passing id and iconk_URLImage for testing loading image in label using following codes 
 
 Hashtable entry = new Hashtable();
    ItemModel itemModel = itemModels.get(index);     
  entry.put("id", "" + itemModel.getId());
  entry.put("iconk_URLImage", itemModel.getImageUrl());

Shai Almog

unread,
Aug 18, 2014, 11:49:19 AM8/18/14
to codenameone...@googlegroups.com
Do you have an iconk label in your renderer (with the name == iconk)?
What about the iconkName entry?
Does the iconk component have an icon assigned to it to serve as the placeholder?

shyam tha

unread,
Aug 19, 2014, 4:35:52 AM8/19/14
to codenameone...@googlegroups.com
1. I am using iconk_URLImage label 
2. iconkName is not used.
3. And I am using resource image for temporary purpose.

Shai Almog

unread,
Aug 19, 2014, 11:04:05 AM8/19/14
to codenameone...@googlegroups.com
The label should be named iconk not iconk_URLImage. You will need iconkName otherwise you will get an exception when this is setup correctly.

shyam tha

unread,
Aug 20, 2014, 12:48:35 AM8/20/14
to codenameone...@googlegroups.com

I am using following listModel



public class ListModel1 implements ListModel {


    private int selected;

    private EventDispatcher selectionListeners = new EventDispatcher();

    private int no;

    private ArrayList<ItemModel> itemModels;

    List list;


    public ListModel1(ArrayList<ItemModel> itemModels, List list) {

        this.list = list;

        this.no = itemModels.size();

        this.itemModels = itemModels;

    }


    public Object getItemAt(int index) {

        

  

        

            Resources res = Resources.openLayered("/theme");

            Image image = res.getImage("setting.png");        

            ItemModel itemModel = itemModels.get(index);


            String name = new ImageUrl().getImageName(itemModel.getImageUrl());


            boolean isImageFound = Storage.getInstance().exists(name);

            entry.put("id", "" + itemModel.getId());


            entry.put("iconk_URLImage", itemModel.getImageUrl());


And getItemAt method is called repeatedly 

and the online image is not still displayed ?
how display online image and handle getItemAt method call?
On Aug 16, 2014 7:58 PM, "Shai Almog" <shai....@gmail.com> wrote:
I don't understand what sort of "clue" you need for something that is a fact that you can't change. Renderer will be invoke a lot since it needs to animate elements into place.

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/ostXxPKQzRU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.

shyam tha

unread,
Aug 20, 2014, 12:48:35 AM8/20/14
to codenameone...@googlegroups.com
I am waiting for your reply
--

Shai Almog

unread,
Aug 20, 2014, 1:02:12 AM8/20/14
to codenameone...@googlegroups.com
You should post thru the web interface. Google delegated 8 of your messages as spam.

Your getItemAt is REMARKABLY slow and would make your app crawl/crash. That method must be instantaneous, you need to cache all the data that you would need and not open a file with every call.

I was talking about your renderer container not your model.

Siripé Ibrahim

unread,
Oct 24, 2014, 7:54:26 AM10/24/14
to codenameone...@googlegroups.com
Hi everybody,
Hope you are doing well, 
I tried icon_URLImage to optimize the loading in multilist below my code
                           
       while (c.next()) 
       {
             hlist = new Hashtable();
             r = c.getRow();
             hlist.put("Line1", r.getString(6));
             hlist.put("Line2", r.getString(8));
             sb.delete(0, sb.length());
             sb.append("alb").append(r.getInteger(4));
             urlcover = r.getString(10); 
             hlist.put("iconName", sb.toString());
             hlist.put("icon_URLImage", urlcover);
             vlist.add(hlist);
        } 
  mlist.setModel(new Model(vlist));
  mlist.setRenderer(createListRenderer(defaultimg));

In createListRenderer my code is :
     private static MultiButton createRendererMultiButton(final Image img) {
        MultiButton b = new MultiButton();
        b.setName("icon");
        b.setIcon(img);
        b.setNameLine1("Line1");
        b.setNameLine2("Line2");
        b.setUIID("Label");
        return b;
    }
    
    private static ListCellRenderer createListRenderer(final Image img) {
        MultiButton sel = createRendererMultiButton(img);
        MultiButton unsel = createRendererMultiButton(img);
        return new GenericListCellRenderer(sel, unsel);
    }

But online image still not display, please help me.
My english is not good so excuse me.
 
Thanks for your help and thanks to Codename One for the great jobs.

Siripé Ibrahim

unread,
Oct 24, 2014, 8:33:53 AM10/24/14
to codenameone...@googlegroups.com
I add below code :
hlist.put("icon", defaultimg); 

PlaceHolder image is loaded but still not update by online image !!!

Shai Almog

unread,
Oct 24, 2014, 9:22:33 AM10/24/14
to codenameone...@googlegroups.com
In the future I suggest opening your own thread. This thread is too long/old to be useful.

You set the name of the multibutton itself which doesn't work that way since it is a composite lead component http://www.codenameone.com/blog/leading
You should use setIconName instead of setName

Siripé Ibrahim

unread,
Oct 24, 2014, 10:15:10 AM10/24/14
to codenameone...@googlegroups.com
I use this thread to avoid double thread, but I understand, it's well noted.
I will udate my code according your advise and revert back with outcome.
Thank you for your kind help !!

Siripé Ibrahim

unread,
Oct 24, 2014, 11:19:42 AM10/24/14
to codenameone...@googlegroups.com

 I update my code according your advise I notice a real improvement of perfomance with URLImage, the placeholder is loaded but my online image is still not update in my multilist. I don't know what to do to resolve this issue since yesterday. (I just open a new thread call MultiList icon_URLImage)


 while (c.next()) 
   {
         hlist = new Hashtable();
         r = c.getRow();

         sb.delete(0, sb.length());
         sb.append("alb").append(r.getInteger(4));
         urlcover = r.getString(10); 
hlist.put("Line1", r.getString(6)); hlist.put("Line2", r.getString(8)); hlist.put("icon", defaultimg); hlist.put("iconName", sb.toString()); hlist.put("icon_URLImage", urlcover); vlist.add(hlist); } mlist.setModel(new Model(vlist)); mlist.setRenderer(createListRenderer()); In createListRenderer my code is : private static MultiButton createRendererMultiButton() { MultiButton b = new MultiButton(); b.setIconName("icon"); b.setNameLine1("Line1"); b.setNameLine2("Line2"); b.setUIID("Label"); return b; } private static ListCellRenderer createListRenderer() { MultiButton sel = createRendererMultiButton(); MultiButton unsel = createRendererMultiButton(); return new GenericListCellRenderer(sel, unsel); }

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/ostXxPKQzRU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
Message has been deleted

Shai Almog

unread,
Oct 24, 2014, 8:47:56 PM10/24/14
to codenameone...@googlegroups.com
Please don't post duplicates.
Reply all
Reply to author
Forward
0 new messages