我想创建一个自定义BitmapField,用于在我的菜单屏幕上放置图标。我希望他们被点击。我还想将图标的X和Y坐标作为参数提供给Custom BitmapField。我怎么能这样做?
答案 0 :(得分: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);
}
}
}
如果要将坐标作为参数添加,请添加它们。高度和宽度取决于你..