×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    7

    Angry problem with LWUIT list scoller

    Hi ,

    I add list to my form , but when I press down or up the form goes down!

    what I want is to go to the next list item , not to closer the form .

    I found these code
    this.listForm = new Form(this.title) {

    public void keyPressed(int keyCode) {
    int game = Display.getInstance().getGameAction(keyCode);
    if (game == Display.GAME_FIRE) {
    selectIt();
    }
    if (game == Display.GAME_DOWN) {
    if (titleist.getSelectedIndex() == (len - 1)) {
    titleist.setSelectedIndex(-1);
    }

    }
    if (game == Display.GAME_UP) {
    if (titleist.getSelectedIndex() == 0) {
    titleist.setSelectedIndex(len);
    }

    }

    super.keyPressed(keyCode);
    }
    };

    I run it on 3 different forms & I get three different results :

    1. work ok.
    2. still scoller the form only.
    3. it sclooer the list item but the form don't go with it , so I can't see which item is selected !


    any suggestion ?

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: problem with LWUIT list scoller

    Make scrollable true for List, fix the container on the form and put the list in the container.

    thanks,
    ~Amitabh

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    7

    Re: problem with LWUIT list scroller

    Quote Originally Posted by im2 amit View Post
    Make scrollable true for List, fix the container on the form and put the list in the container.

    thanks,
    ~Amitabh
    what I do now is butting the form scrollable false .

    I create many object from the same form , although its work for 2/3 times ! the other 1/3 the form is stopped and no scrollable done at all !

    so , How I can set the list scrollable to true what is the exact function .

    thanks so much.

  4. #4
    Regular Contributor
    Join Date
    May 2007
    Location
    India
    Posts
    208

    Re: problem with LWUIT list scoller

    Please give more details like, what all types of form are there. And it works for which form and for which form it doesn't.
    Generally, you don't have to do anything with list but simply make the scrollable of Form false using following line:

    f.setScrollable(false);

    where f is instance of LWUIT Form.
    Last edited by gaurav007; 2010-04-21 at 19:01.

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    7

    Re: problem with LWUIT list scoller

    Quote Originally Posted by gaurav007 View Post
    Please give more details like, what all types of form are there. And it works for which form and for which form it doesn't.
    hi ,

    I'm using : com.sun.lwuit.Form;

    I create several objects from the same Form class it's work in some objects but the other no !!

    I use the form to display RSS item using kxmlrss.

    the code is :
    Code:
    package com.Riyadh.kxmlrss.display;
    
    import RiyadhStyle.RStyle;
    import com.Riyadh.main.Riyadh;
    import com.Riyadh.main.TodayEdition;
    import com.jappit.wiki.kxmlrss.parser.KXmlRssParser;
    import com.jappit.wiki.kxmlrss.parser.RssItem;
    import com.sun.lwuit.Component;
    
    import com.sun.lwuit.Form;
    import com.sun.lwuit.List;
    import com.sun.lwuit.events.ActionEvent;
    import com.sun.lwuit.list.ListCellRenderer;
    import com.sun.lwuit.Command;
    
    
    import com.sun.lwuit.Container;
    
    import com.sun.lwuit.Display;
    import com.sun.lwuit.layouts.BoxLayout;
    import com.sun.lwuit.TextArea;
    import com.sun.lwuit.events.ActionListener;
    import com.sun.lwuit.layouts.BorderLayout;
    import java.util.Vector;
    import javax.microedition.io.ConnectionNotFoundException;
    
    public class TitleList implements ActionListener {
    
        private Form listForm;
        private Command back;
        private Command main;
        private Command open;
        private Riyadh riyadh;
        private String[] link;
        private int selected;
        private RStyle style;
        private TodayEdition tody;
        private List titleList;
        String title;
    
        public TitleList(String URL, String t, Riyadh r, TodayEdition td, RStyle s) {
            Vector rssItems = null;
            riyadh = r;
            tody = td;
            title = t;
            style = s;
    
    
    
            KXmlRssParser parser = new KXmlRssParser();
    
            try {
    
    
                byte[] UrlName = URL.getBytes("UTF-8");
                URL = new String(UrlName);
    
                rssItems = parser.parse(URL);
                FormInt(rssItems.size());
                link = new String[rssItems.size()];
    
    
                for (int i = 0; i < rssItems.size(); i++) {
    
                    String titles = ((RssItem) rssItems.elementAt(i)).title;
                    String UTFTitle = new String(titles.getBytes(), "UTF-8");
                    titleList.addItem(UTFTitle);
    
    
                    link[i] = ((RssItem) rssItems.elementAt(i)).link;
    
    
                }
            } catch (Exception e) {
                TextArea error = new TextArea("Error: " + e);
                this.listForm.addComponent(error);
    
                e.printStackTrace();
            }
    
    
        }
    
        public void FormInt(final int len) {
            this.listForm = new Form(this.title) {
    
                public void keyPressed(int keyCode) {
                    int game = Display.getInstance().getGameAction(keyCode);
                    if (game == Display.GAME_FIRE) {
                        selectIt();
                    }
                    if (game == Display.GAME_DOWN) {
                        if (titleList.getSelectedIndex() == (len - 1)) {
                            titleList.setSelectedIndex(-1);
                        }
    
                    }
                    if (game == Display.GAME_UP) {
                        if (titleList.getSelectedIndex() == 0) {
                            titleList.setSelectedIndex(len);
                        }
    
                    }
    
                    super.keyPressed(keyCode);
                }
            };
    
    
                  listForm.setLayout(new BoxLayout (BoxLayout.Y_AXIS));
           // listForm.setStyle(style.FormStyle());
            //listForm.setTitleStyle(style.titleStyle());
        
    
    
            if (tody != null) {
                back = new Command("عودة", 1);
                listForm.addCommand(back);
            }
            main = new Command("الرئيسية", 2);
            listForm.addCommand(main);
            open = new Command("فتح", 3);
            listForm.addCommand(open);
            listForm.setCommandListener(this);
            titleList = new List();
            titleList.setStyle(style.listStyle());
            titleList.setBorderGap(0);
            titleList.setItemGap(0);
    
            titleList.setListCellRenderer(new ListRender(listForm));
            listForm.addComponent(titleList);
            listForm.setScrollable(false);
            listForm.setMenuCellRenderer(new ListRender(listForm));
           
    
    
    
        }
    
        private void selectIt() {
            try {
                System.out.println("link:" + link[selected]);
                String url = link[selected].substring(11);
                System.out.println("link:" + url);
    
    
                riyadh.platformRequest("http://" + url);
            } catch (ConnectionNotFoundException ex) {
                ex.printStackTrace();
            }
        }
    
        public void showListForm() {
            listForm.show();
        }
    
        public void actionPerformed(ActionEvent ae) {
            switch (ae.getCommand().getId()) {
                case 1:
                    tody.ShowForm();
                    break;
                case 2:
                    riyadh.ShowMainForm();
                    break;
                case 3:
                    selectIt();
    
    
                    break;
    
            }
        }
    
        /******************************************************************
         **                                                              **
         **                          class SettingRenderer               **
         ** this class use ListCellRender java interface, which help to  **
         ** set list in spicifc format.                                  **
         ** https://lwuit.dev.java.net/nonav/javadocs/index.html         **
         **                                                              **
         ******************************************************************/
        class ListRender implements ListCellRenderer {
    
            private Form form;
    
            public ListRender(Form f) {
    
                form = f;
    
    
            }
            // function get active when user move to next item.
    
            public Component getListCellRendererComponent(List chatList,
                    Object value, int itemIndex, boolean isSelected) {
    
    
                Container cnt;
                cnt = new Container();
    //            cnt.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
                // set selscted list item.
                // ex: message = "laguge".
                String message = value.toString();
                //get 1st letter to use it in switch command.
                selected = itemIndex;
    
                //set it to form.
                TextArea TitleBox = new TextArea(message, 5, this.form.getWidth());
                //make the text area non editable
                TitleBox.setEditable(false);
                //make the text area scroll nonVisible
                TitleBox.setIsScrollVisible(false);
                //make the text area grow
                TitleBox.setGrowByContent(true);
    
    
    
                //if the text area is selected
                if (TitleBox.hasFocus()) {
                    //make it focus (which will have another color than the other text area)
                    TitleBox.setFocus(true);
                    TitleBox.setStyle(style.TextStyle());
    
    
                } //if the text area is not selected
                else {
                    //make it no focus
                    TitleBox.setFocus(false);
    
    
    
                }
                cnt.addComponent(TitleBox);
    
                // if item is selected now.
                if (isSelected) {
                    cnt.setFocus(true);
                    TitleBox.setStyle(style.TextStyle());
                } else {
                    cnt.setFocus(false);
                }
    
    
    
                return cnt;
    
            }
    
            public Component getListFocusComponent(List arg0) {
                Container cnt = new Container();
    
                //   cnt.getStyle().setBgTransparency(100);
                return cnt;
            }
        }//end inner class.
    }

    thanks for your help

  6. #6
    Registered User
    Join Date
    Sep 2008
    Posts
    7

    Re: problem with LWUIT list scoller

    Quote Originally Posted by gaurav007 View Post
    Please give more details like, what all types of form are there. And it works for which form and for which form it doesn't.
    Generally, you don't have to do anything with list but simply make the scrollable of Form false using following line:

    f.setScrollable(false);

    where f is instance of LWUIT Form.
    I do . but as I say it not work all the time

    I create about 15 objects from the class I just submit , it work on 10 objects only !

  7. #7
    Regular Contributor
    Join Date
    May 2007
    Location
    India
    Posts
    208

    Re: problem with LWUIT list scoller

    Can you try the following line with your list:

    PHP Code:
    list.setFixedSelection(List.FIXED_NONE_CYCLIC); 

  8. #8
    Registered User
    Join Date
    Sep 2008
    Posts
    7

    Re: problem with LWUIT list scoller

    Quote Originally Posted by gaurav007 View Post
    Can you try the following line with your list:

    PHP Code:
    list.setFixedSelection(List.FIXED_NONE_CYCLIC); 
    Nothing happened

    thanks ,

  9. #9
    Regular Contributor
    Join Date
    May 2007
    Location
    India
    Posts
    208

    Re: problem with LWUIT list scoller

    Can you put more observations - like with what kind of forms it works. I know that you've created onjects of same class but there must be differnece in terms of number of list elements or the appearance of form...

  10. #10
    Registered User
    Join Date
    Sep 2008
    Posts
    7

    Re: problem with LWUIT list scoller

    Quote Originally Posted by gaurav007 View Post
    Can you put more observations - like with what kind of forms it works. I know that you've created onjects of same class but there must be differnece in terms of number of list elements or the appearance of form...
    realy I don't Know what is the diffrence

    all what I do is reading rss from news paper


    these is working :

    Code:
     if (this.mainList[LAST_NEWS].getState() == Button.STATE_ROLLOVER) {
                TitleList tl = new TitleList("http://www.alriyadh.com/section.news.xml", "آخر خبر", this ,null,style);
    
                tl.showListForm();
            } else if (this.mainList[this.PIC_NEWS].getState() == Button.STATE_ROLLOVER) {
                TitleList tl = new TitleList("http://www.alriyadh.com/section.photo.xml", "الأخبار المصورة", this,null,style);
                tl.showListForm();
            } else if (this.mainList[this.WEB_SITE].getState() == Button.STATE_ROLLOVER) {
                try {
                    System.out.print("here");
                    this.platformRequest("http://alriyadh.com/mobile");
                } catch (ConnectionNotFoundException ex) {
    
                    Dialog.show("خطأ", "عذراً لم يتم العثور على الاتصال", Dialog.TYPE_ERROR, null, "ok", null);
                }
            } else if (this.mainList[this.TODAY_CHAR].getState() == Button.STATE_ROLLOVER) {
                TitleList tl = new TitleList("http://www.alriyadh.com/section.comic.xml", "الكاريكتير", this,null,style);
                tl.showListForm();
            } else if (this.mainList[this.PIC_DATA].getState() == Button.STATE_ROLLOVER) {
                TitleList tl = new TitleList("http://www.alriyadh.com/file.568.xml", "قوائم وبيانات", this,null,style);
                tl.showListForm();
            }
            else if (this.mainList[this.E_NEWS].getState() == Button.STATE_ROLLOVER) {
                TitleList tl = new TitleList("http://www.alriyadh.com/section.alriyadhnet.epress.xml", "الصحفي الالكتروني", this,null,style);
                tl.showListForm();
    but these not

    Code:
      TitleList tl = new TitleList(URLs[selected], settingSections[selected], main, this, style);
    which URLS & settingSections is array of strings ..


    I try to sawp the urls & it still not working !

Similar Threads

  1. Can't find Serial Port
    By AliceC in forum Symbian
    Replies: 3
    Last Post: 2009-10-15, 11:23
  2. Problem in Going Back from Form to List
    By lopesrohan1988 in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-07-07, 08:11
  3. LWUIT List heigth
    By stanleek in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2009-05-27, 11:39
  4. setting list problem
    By ddhungry in forum Symbian
    Replies: 0
    Last Post: 1970-01-01, 02:00
  5. setting list problem
    By ddhungry in forum Symbian User Interface
    Replies: 0
    Last Post: 1970-01-01, 02:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×