Search code examples
blackberrylistfield

how to select all items at a time when cliking on select all menuitem for a listfield checkbox in blackberry


I want to select all items in a listfield at a time when cliking on the select all menu item in the application.i tried with my code like this..

selectall = new MenuItem("Selectall", 200, 10){
            public void run(){
            int elementLength = _elements.length;
             for(int count = 0; count < elementLength; ++count)
                {
            _listData.addElement(new ChecklistData(_elements[count], true));
            listField.insert(count);
                }
            }
        };

but iam getting the result with old list also.below the old list this new list is coming with checked.how to solve that.please give your ideas.and where iam doing the mistake.thanks in advance..


Solution

  • Thanks for your all suggestions. i solved my problem now..the solution is..

    selectall = new MenuItem("Selectall", 200, 10){
                public void run(){
    
                    int elementLength = _elements.length;
                    for(int count = 0; count < elementLength; ++count)
                    {
                        _listData.setElementAt(new ChecklistData(_elements[count], true), count);
    
                    }
                }
            };