Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6729317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:16:31+00:00 2026-05-26T10:16:31+00:00

I am developing custom list field using Table Row Manager in blackberry.it displays list

  • 0

I am developing custom list field using Table Row Manager in blackberry.it displays list of items coming from web service.When i click on item it goes to other screen.But i am getting too many threads exception.after some time i am getting too many threads exception when i click on item.Then i check when the thread is creating by using debug.Then i found of displaying each item it creating separate thread.How can i solve this problem please help here is my custom list field class

class LabelListField extends ListField implements ListFieldCallback 
{
    private Vector mValues;
    private Vector mRows;
    DynamicImages images;
    int[] intColor=new int[500];
    int i=0;
    int j=0,position;
    static int value1=0;
    String key;
    String[] col;
    public LabelListField(Vector values,int p,String key) {
        super(0);
        setRowHeight(70);
        setCallback(this);
        position=p;
        mValues = values;
        this.key=key;
        fillListWithValues(values);
        images=new DynamicImages();
        scheduleInvalidate();
    }

    private void scheduleInvalidate() {
        Timer timer = new Timer();
        timer.scheduleAtFixedRate(new TimerTask() {
            public void run() {
                invalidate();
            }
        }, 0, 100);
    }

    private void fillListWithValues(Vector values) {
        mRows = new Vector();
        for (;i< values.size();i++) {

           TableRowManager row = new TableRowManager();
           String value = (String) values.elementAt(i);
            ListLabel valueLabel = new ListLabel(this,i,value);
            if(Display.getWidth()==480)
            {
            valueLabel.setFont(Utility.getBigFont(16));
            }
            else
            {
            valueLabel.setFont(Utility.getBigFont(12)); 
            }
            row.add(valueLabel);

            mRows.addElement(row);
        }

        setSize(mRows.size());
    }

    private class TableRowManager extends Manager {
        public TableRowManager() {
            super(0);
        }

        public void drawRow(Graphics g, int x, int y, 
            int width, int height) {
            layout(width, height);
            setPosition(x, y);
            g.pushRegion(getExtent());
            paintChild(g, getField(0));
            Bitmap line=Bitmap.getBitmapResource(images.lightline);
            g.drawBitmap(0,0,line.getWidth(),line.getHeight(),line,0,0);
            g.popContext();
        }
    protected void sublayout(int width, int height) {
            int fontHeight = Font.getDefault().getHeight();
            int preferredWidth = getPreferredWidth();
            Field field = getField(0);
            layoutChild(field, preferredWidth,fontHeight + 1);
            if(((ListLabel)field).getText().length()>110)
            {
            setPositionChild(field, 5,10);
            }
            else if(((ListLabel)field).getText().length()>55)
            {
             setPositionChild(field,5,20);
            }
            else if(((ListLabel)field).getText().length()<55)
            {
             setPositionChild(field,5,30);
            }
            //field = getField(1);
            //layoutChild(field,18,24);
            //setPositionChild(field,250,30);
            setExtent(getPreferredWidth(), getPreferredHeight());
        }

        public int getPreferredWidth() {
            return Display.getWidth();
        }

        public int getPreferredHeight() {
            return getRowHeight();
        }
    }

    public void drawListRow(ListField listField, Graphics g, 
            int index, int y, int width) {


        String val=HomeScreenIcons.colorstable.get(key).toString();
        col=StringToken.split(val,"||");
        if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS))
        {
        LabelListField list = (LabelListField) listField;
        g.setColor(0xC0C0C0);
        g.fillRect(0,y+0,480,list.getRowHeight());
        if(col[index].equals("1"))
        {

         g.setColor(0x004D7B);  
        }
        else
        {

             g.setColor(Color.GRAY);    

        }
        TableRowManager rowManager = (TableRowManager) list.mRows
                .elementAt(index);

        rowManager.drawRow(g,0,y,width,list.getRowHeight());
        }
        else
        {
            if(col[index].equals("1"))
            {

            g.setColor(0x004D7B);   
            }
            else
            {
            g.setColor(Color.GRAY); 

            }
            LabelListField list = (LabelListField) listField;
            TableRowManager rowManager = (TableRowManager) list.mRows
                    .elementAt(index);
            rowManager.drawRow(g,0,y,width,list.getRowHeight());
        }

    }

    public Object get(ListField list, int index) {
        return mValues.elementAt(index);
    }

    public int indexOfList(ListField list, String prefix, int start) {
        for (int x = start; x < mValues.size(); ++x) {
            String value = (String) mValues.elementAt(x);
            if (value.startsWith(prefix)) {
                return x;
            }
        }
        return -1;
    }

    public int getPreferredWidth(ListField list) {
        return Display.getWidth();
    }

    class ListLabel extends LabelField {
        int mIndex = -1;
        String text;
        int[] color=new int[500];
        public ListLabel(LabelListField list, int index, String text) {
            super(text);
            this.text=text;
            mIndex = index;
            System.out.println("position is"+position);

        }

         public int getPreferredWidth() { 
             return Display.getWidth()-80; 
         } 

         protected void layout(int maxWidth,int maxHeight) {
             super.layout(getPreferredWidth(),maxHeight);
             setExtent(getPreferredWidth(), getHeight());
         }
    protected boolean navigationClick(int status, int time) {
                 fieldChangeNotify(0);
                 return true;
               }
               protected void fieldChangeNotify(int context){
                 if(context == 0){
                   try {
                     this.getChangeListener().fieldChanged(this, context);
                   } catch (Exception e){}
                 }
               }
    }
    protected boolean trackwheelClick(int status, int time)
    {
        return true;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:16:31+00:00Added an answer on May 26, 2026 at 10:16 am

    useless Calling of scheduleInvalidate method.By removing scheduleInvalidate() it works fine

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an custom API for a web solution and I am using
I am developing an app in which i am using custom list tab,By using
Does anyone have any good links for developing custom field and content types that
I am developing a custom control derived from System.Windows.Controls.ContentControl. In the controls default template
I'm currently developing a custom control that derives from CStatic MFC class (Smart Device
I'm developing a system to pick up XML attachments from emails, via Exchange Web
I'm developing a custom Adsense report tool using Google Java Client Library for Android
I'm developing a custom webpart for SharePoint 2007 using C# and Visual Studio. I
I am developing a sharepoint 2007 web part that uses custom properties. Here is
I'm developing a Silverlight application that displays items in a listbox control and I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.