Search code examples
blackberrycolorsbackgroundhighlightlistfield

Highlight color vanishes after adding background color to the listfield in BlackBerry


I have managed to ge the list items in the ListField and am able to recognize which item was clicked using the navigationClick method. Now I have also added a different background to my ListField by overriding the paint method. I am basically giving a zebra pattern to the Listview to differentiate the list items. But now I am unable to view the Highlight. But when i scroll down the list and click, it recognizes the item. so any idea where am going wrong or how i can change the highlight color?

Working on: Device: 8520 OS: 5.0

Thanks in advance


Solution

  • As jprofitt points out, you should use drawListRow to make better use of the ListField.

    For the focus issue, ListField will handle the focus drawing for you. It will be drawn before your paint code is called, so to avoid wiping out the focus color, you need to stop drawing the zebra striping for the selected row. If you add continue logic to the top of your loop, you will start seeing the selector again.

    if(x == getSelectedIndex()) { continue; }
    

    You will also want to update your painting logic to use colors that contrast well with the blue highlight color, but only for the selected row.