我想创建一个自定义位图字段,用于将图标放在我的菜单屏幕上。我希望他们被点击。我还想将图标的 X 和 Y 坐标作为自定义位图字段的参数。我怎样才能做到这一点?
问问题
853 次
1 回答
0
public class CustomMenuButtonField extends Field{
Bitmap normal,focused;
public CustomMenuButtonField(String bitmap1, String bitmap2) {
normal = Bitmap.getBitmapResource(bitmap1);
focused = Bitmap.getBitmapResource(bitmap2);
}
protected void layout(int width, int height) {
setExtent(width, height); // Set them according to your design
}
protected boolean navigationClick(int status, int time)
{
fieldChangeNotify(0);
return true;
}
public boolean isFocusable() {
return true;
}
protected void paint(Graphics graphics) {
if(isFocus())
{
graphics.drawBitmap(0, 0, width, height, focused, 0, 0);
}
else
{
graphics.drawBitmap(0, 0, width, height, normal, 0, 0);
}
}
}
如果您想将坐标作为参数,请添加它们。高度和宽度由你决定..
于 2011-04-28T19:03:02.470 回答