我有一个按钮字段。它的颜色是红色的。当我点击它的颜色按钮应该变成黑色如何做到这一点?如何更改点击按钮的颜色
1
A
回答
1
您是否尝试过本教程“Blackberry Custom Button Field”,或者您也可以制作背景设置为一种颜色的位图字段,并为所需更改实施自定义绘画方法。
1
如果您的按钮是一个a class="button"
标签,你可以做这样的:
a.button {
color: black;
}
1
可以与RIM官方文档的"Tutorial: Creating a custom button"尝试。
我觉得这是你寻找
0
什么用 -
image1的是红色的彩色图像按钮和图像2是黑色
reg_can_btn editprofile = new reg_can_btn("", Field.FOCUSABLE |FIELD_HCENTER, image1, image2, 0x102839);
然后
public class edit_profile_btn extends Field {
private String _label;
private int _labelHeight;
private int _labelWidth;
private Font _font;
private Bitmap _currentPicture;
private Bitmap _onPicture;
private Bitmap _offPicture;
int color;
public edit_profile_btn(String text, long style ,String img, String img_hvr, int color){
super(style);
_offPicture = Bitmap.getBitmapResource(img);
_onPicture = Bitmap.getBitmapResource(img_hvr);
_font = getFont();
_label = text;
_labelHeight = _onPicture.getHeight();
_labelWidth = _onPicture.getWidth();
this.color = color;
_currentPicture = _offPicture;
}
/**
* @return The text on the button
*/
String getText(){
return _label;
}
/**
* Field implementation.
* @see net.rim.device.api.ui.Field#getPreferredHeight()
*/
public int getPreferredHeight(){
return _labelHeight;
}
/**
* Field implementation.
* @see net.rim.device.api.ui.Field#getPreferredWidth()
*/
public int getPreferredWidth(){
return _labelWidth;
}
/**
* Field implementation. Changes the picture when focus is gained.
* @see net.rim.device.api.ui.Field#onFocus(int)
*/
protected void onFocus(int direction) {
_currentPicture = _onPicture;
invalidate();
}
/**
* Field implementation. Changes picture back when focus is lost.
* @see net.rim.device.api.ui.Field#onUnfocus()
*/
protected void onUnfocus() {
_currentPicture = _offPicture;
invalidate();
}
/**
* Field implementation.
* @see net.rim.device.api.ui.Field#drawFocus(Graphics, boolean)
*/
protected void drawFocus(Graphics graphics, boolean on) {
// Do nothing
}
/**
* Field implementation.
* @see net.rim.device.api.ui.Field#layout(int, int)
*/
protected void layout(int width, int height) {
setExtent(Math.min(width, getPreferredWidth()),
Math.min(height, getPreferredHeight()));
}
/**
* Field implementation.
* @see net.rim.device.api.ui.Field#paint(Graphics)
*/
protected void paint(Graphics graphics){
// First draw the background colour and picture
//graphics.setColor(this.color);
graphics.setBackgroundColor(Color.BLACK);
graphics.fillRect(0, 0, getWidth(), getHeight());
graphics.drawBitmap(0, 0, getWidth(), getHeight(), _currentPicture, 0, 0);
// Then draw the text
graphics.setColor(Color.BLACK);
graphics.setFont(_font);
graphics.drawText(_label, 4, 2,
(int)(getStyle() & DrawStyle.ELLIPSIS | DrawStyle.HALIGN_MASK),
getWidth() - 6);
}
/**
* Overridden so that the Event Dispatch thread can catch this event
* instead of having it be caught here..
* @see net.rim.device.api.ui.Field#navigationClick(int, int)
*/
protected boolean navigationClick(int status, int time){
fieldChangeNotify(1);
return true;
}
}
1
试试这个它是工作,
public int checkBoxFlag1 = 0;
public int checkBoxFlag2 = 0;
public int checkBoxFlag3 = 0;
final Bitmap focuscheckButton = Bitmap.getBitmapResource("checkbox_tickmark.png");
final Bitmap unfocuscheckButton = Bitmap.getBitmapResource("checkbox.png");
HorizontalFieldManager checkBoxFieldManager = new HorizontalFieldManager();
BitmapField checkBox1 = new BitmapField(unfocuscheckButton,Field.FOCUSABLE)
{
protected void paint(Graphics graphics)
{
// TODO Auto-generated method stub
if(checkBoxFlag1==0)
{
this.setBitmap(unfocuscheckButton);
}
else
{
this.setBitmap(focuscheckButton);
}
super.paint(graphics);
}
protected boolean navigationClick(int status, int time)
{
// TODO Auto-generated method stub
if(checkBoxFlag1==0)
{
checkBoxFlag1=1;
}
else
{
checkBoxFlag1=0;
}
return super.navigationClick(status, time);
}
};
checkBox1.setMargin(0,20,0,20);
checkBoxFieldManager.add(checkBox1);
相关问题
- 1. 如何更改颜色点击按钮?
- 2. 更改点击按钮的颜色
- 3. 点击更改javafx按钮颜色?
- 4. 点击更改按钮颜色
- 5. 如何更改未点击的按钮的背景颜色?
- 6. Xcode - 更改按钮上的按钮背景颜色点击
- 7. 如何更改按钮上的textView文本颜色点击
- 8. 如何保存在用户点击的按钮更改颜色
- 9. 如何在点击按钮时更改矩形的颜色?
- 10. 离子 - 如何更改点击时的按钮颜色
- 11. 如何在Android中点击时更改按钮的颜色?
- 12. 如何更改(并保持)点击按钮的颜色
- 13. 如何更改按钮的颜色它被点击DHTMLX
- 14. 如何更改按钮上的组件颜色点击
- 15. 如何更改笔在按钮上的颜色笔点击android
- 16. 点击按钮改变ImageView的颜色?
- 17. 更改按钮点击按钮颜色暂时在C#
- 18. 如何将按钮背景颜色更改为点击操作?
- 19. 点击(Javascript)时如何更改按钮颜色?
- 20. 如何更改背景颜色,当我点击一个按钮
- 21. 如何在android中更改按钮选择或点击颜色?
- 22. 如何更改Android按钮点击颜色
- 23. 如何通过点击按钮来更改网格颜色?
- 24. 如何在点击切换按钮时更改背景颜色?
- 25. 更改点击的按钮的颜色和关断单击
- 26. 当我点击另一个按钮时如何更改按钮的颜色?
- 27. 点击按钮颜色没有改变
- 28. 单击时更改按钮颜色(多次单击/颜色)
- 29. 更改NavigationDrawer的颜色点击颜色
- 30. 如何更改按钮的tabcontrol颜色?
你想改变什么,背景颜色或文字颜色? – donturner