在点击位图上更改图片

时间:2012-06-26 16:17:56

标签: blackberry bitmap onclick

点击位图check_box1

后如何更改其他check_box2的位图check_box1
btmp_on = EncodedImage
            .getEncodedImageResource("btn_check_on.png");

    btmp_off = EncodedImage
            .getEncodedImageResource("btn_check_off.png");
    Bitmap check_box1 = getScaledBitmapImage(btmp_off,30,40);
    Bitmap check_box2 = getScaledBitmapImage(btmp_on,30,40);

1 个答案:

答案 0 :(得分:0)

请参阅以下链接:

For CustomListField

并且对于触摸设备,将 fieldChanged 中的相同代码添加到 touchEvent 像:

protected boolean touchEvent(TouchEvent message) 
{
    switch( message.getEvent() ) 
    {          
        case TouchEvent.CLICK:
            clickButton();
            break;

        default: break;
    }
    return super.touchEvent(message);
}
private void clickButton()
{
    Field focussedOne=this.getLeafFieldWithFocus();//Means this is the last field which is not having any otherFields;
    for(int i=0;i<size;i++)
    {
        if(focussedOne==listStyleButtonField[i])
        {
            if(listStyleButtonField[i].getChanged())
                listStyleButtonField[i].changeBitmap(bitmap,false);
            else
                listStyleButtonField[i].changeBitmap(bitmapHover,true);
        }
    }
}