开发者

How to change row color background in a ListField after navigation Click?

开发者 https://www.devze.com 2023-03-27 01:46 出处:网络
I\'m beginner in BB dev.I create a CustomListField and when I click on a row, the background color of this row must change and a new screen must be displayed (it\'s done!).

I'm beginner in BB dev. I create a CustomListField and when I click on a row, the background color of this row must change and a new screen must be displayed (it's done!).

Could any one please help me to get this done? thx

Below is the code:

protected boolean navigationClick(int status, int time)
       {Field field = this.getLeafFieldWithFocus();

       if(field instanceof ListField)
       {
         // listValues is String[] where you store your list elements.
         // listField is the ListField instance you are using 
           UiApplication.getUiApplication().pushScreen(new ReadMsgScreen());

           int index= getIndex();
           if(index== t开发者_运维知识库his.getSelectedIndex())
           {
               **// I think the  code to change the row's background color must be set here!**

           }

          return true;
        }

       return super.navigationClick(status, time);
   }


use this it will definately work...

int tmpcolor = graphics.getColor();
graphics.setColor(Color.CYAN);
graphics.fillRect(0, y, width, getRowHeight());
graphics.setColor(tmpcolor);

thanks...


onerride the paint() method in blackberry as showed the code below..

_specialNumbers = new LabelField(Constants.SPECIAL_NUMBERS,LabelField.USE_ALL_WIDTH) {
            protected void paintBackground(Graphics arg0) {
                int color = arg0.getBackgroundColor();
                arg0.setBackgroundColor(Color.LIGHTGREY);
                arg0.clear();
                arg0.setBackgroundColor(color);
            }
        };


In the drawListRow() method of the ListFieldCallback for your CustomListField draw that selected line differently and call a Transition to display the other Screen slowly.

0

精彩评论

暂无评论...
验证码 换一张
取 消