Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
OscarQ
Posts: 18
Registered: ‎03-02-2012
My Device: BlackBerry 9300
Accepted Solution

Problem with ListField

Hi everyone,

 

when user click in a ListField i want to update an image of a row but i didn't get it. 

 

My purpose is simulate a checkbox, it means that by default in the end of the row there is an unchecked image and when user click there is a checked image.

I tried to overwrite drawListRow of ListFieldCallback but i don't know how update the row when user click to change the unchecked image with the checked image.

 

Any help is welcome, thanks very much!!

Please use plain text.
Contributor
Dsheel
Posts: 24
Registered: ‎01-24-2011
My Device: 4.2.1(8800), 4.6(9000), 4.7 and above

Re: Problem with ListField

 

Inside drawListRow() use the Graphics and ListField object and do the following:

 

static boolean boolean checkedflag = false;

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

 

  if (listField.getSelectedIndex() != -1)) {  //i.e a row gets selected
       

           if(checkedFlag){
                      graphics.drawBitmap(...,...,UnCheckedBitmap,...);

                      checkedFlag = false;

                    

           }

           else

                      graphics.drawBitmap(...,...,CheckedBitmap,...);

                      checkedFlag = true;
           }      

}

The above code may require some fine tuning!...but graphics.drawBitmap() will work just fine.

Please use plain text.
Developer
simon_hain
Posts: 16,215
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Problem with ListField

welcome to the support forums.

you can find the appropriate sample by using the search box on the top right of the screen.

here is the link:
http://supportforums.blackberry.com/t5/Java-Development/Create-a-ListField-with-check-boxes/ta-p/443...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
OscarQ
Posts: 18
Registered: ‎03-02-2012
My Device: BlackBerry 9300

Re: Problem with ListField

Thanks very much to both.

Simon, I had already looked the example but i ddidn´t see the most important line: invalidate()  

This call repaint the selected row :smileyhappy:

 

Dsheel, geSelectedIndex() isn't a good condition because when focus is on row, this return true and I only want to change the image when row is pressed. So it is necessary create a class like the example class, ChecklistData.

 

To sum up, apologize for my english and thanks veye much!!

 

Regards.

Please use plain text.