×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    33

    Custom list: 2 questions

    I'm creating my own custom list which contains many CustomItems. I try to make something like this but then for my nokia 5800:
    http://www.androidtvgids.nl/images/nu-straks.png

    Is it good to have many CustomItems combined in one form, or is it better to have one custom item containing and drawing all elements?

    This are my two problems:
    The first time I tap on an item the item must be selected. But the second time I tap on an item an action must be done, for example open anoter displayable. Just like a standard list in j2me.
    But how can I fire a command to the form that tells that an item is clicked?
    In other words: I want to have a SELECT_COMMAND just like in a standard list.

    The second problem I have is that the CustomItems are not painted when they are created but only when they are on screen.
    Now when I scroll the screen I first see white fields till the Item is loaded.
    Is there something to let the CustomItem paint himself when he is created so that it's allready painted when I scroll my list?

    Last problem: how can I redraw all items when the screen is rotated?
    Now all items are rotated automaticaly but their size is not updated.

    This is how I draw my customitem:
    Code:
            protected void paint(Graphics g, int width, int height)
            {
                Font smallfont = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
    
                g.setColor(0);
                g.fillRect(0, 0, width, height);
    
                if (selected)
                {
                    g.setColor(150, 0, 0);
                    g.fillRoundRect(0, 0, width, height, 15, 15);
                }
    
                if (this.toonzenderimage)
                {
                    g.setColor(80, 80, 80);
                    g.drawLine(5, 0, width - 5, 0);
                    if (this.p_zenderimage != null)
                    {
                        g.drawImage(this.p_zenderimage, 0, 10, Graphics.TOP | Graphics.LEFT);
    
                    }
                }
    
                if (this.p_isbezig)
                {
                    g.setColor(255, 255, 255);
                    g.drawRoundRect(70, 65, width - 75, 10, 10, 10);
                    g.setColor(255, 200, 0);
                    g.fillRoundRect(72, 67, 4, 7, 8, 8);
                    g.fillRect(75, 67, 240 * programma.GetoondPercentage() / 100, 7);
                }
    
                g.setColor(255, 255, 255);
                g.setFont(smallfont);
                g.drawString(this.p_begintijd, 70, 15, Graphics.TOP | Graphics.LEFT);
                g.drawString(this.p_naam, 130, 15, Graphics.TOP | Graphics.LEFT);
    
            }
    
            protected boolean traverse(int direction, int viewportWidth, int viewportHeight, int[] visRect_inOut)
            {
                selected = true;
                repaint();
                return true;
            }
    
            public void traverseOut()
            {
                selected = false;
                repaint();
            }
    And this is how I add an CustomItem to my form;
    Code:
                        NeSItem nesitem = new NeSItem(pNu, true);
                        this.append(nesitem);
    My form contains 40 customitems.

    Thanks on advance!
    Last edited by twtb; 2010-06-09 at 22:16.

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    33

    Re: Custom list: 2 questions

    Now I tried to put the complete list in one customitem. But now not all items are shown.
    Does a customitem have a maximum height?

    And what is the best solution, one customitem with all the list items or multiple customitems with one customitem for each list item?

  3. #3
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Custom list: 2 questions

    Quote Originally Posted by twtb View Post
    Now I tried to put the complete list in one customitem. But now not all items are shown.
    Does a customitem have a maximum height?

    And what is the best solution, one customitem with all the list items or multiple customitems with one customitem for each list item?
    Yes, you have to manage the scoll of list items within your custom item.

    One custome list of items should be good.
    Thanks,
    Ekta

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    33

    Re: Custom list: 2 questions

    But then the scrollbar on the right side of the form is not correct anymore?
    Do you have an example about creating long lists with customitem?
    And now when I add my customitem on the form it is first white till it's painted, is it possible to make that color black by default?

  5. #5
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Custom list: 2 questions

    Try some UI libs like LWUIT, you can customize it simply to get what you want and it supports all required features.
    Thanks,
    Ekta

  6. #6
    Registered User
    Join Date
    Oct 2008
    Posts
    33

    Re: Custom list: 2 questions

    No I don't want to us LWUIT because i think customitems are more flexible. Now I can draw a progressbar on some list items.

    My first idea of drawing every list item on a different customitem is the best i think. Then I have no problems with the maximum customitem size.
    The only problem i have then is that my customitems are not painted when they are invisible. And when they become visible painting goes to slow.
    I also see white rectangles when the items are painted, can this default color be changed to black?

Similar Threads

  1. Using a custom font questions
    By Infernal01 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 9
    Last Post: 2009-12-02, 11:16
  2. Custom List doesn't view all list items...
    By dusanbaranec in forum Mobile Java General
    Replies: 2
    Last Post: 2005-06-09, 03:10
  3. some questions about custom bluetooth UI
    By wudilp in forum Bluetooth Technology
    Replies: 2
    Last Post: 2005-02-23, 13:06
  4. some questions about custom bluetooth UI
    By wudilp in forum Symbian
    Replies: 2
    Last Post: 2004-03-26, 11:21
  5. some questions about custom bluetooth UI
    By wudilp in forum Bluetooth Technology
    Replies: 0
    Last Post: 2004-03-25, 15:19

Posting Permissions

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