嗨,我已經在我的屏幕上生成自定義佈局,我想要改變水平字段管理器的顏色或圖像時,它的焦點,還執行選定的水平字段管理器的Click事件。對於 更多參考請參閱屏幕截圖。我如何在黑莓中的自定義水平字段管理器和點擊事件中設置焦點?
這是我的代碼,我曾嘗試..
HorizontalFieldManager hfmrow=new HorizontalFieldManager(USE_ALL_WIDTH|HorizontalFieldManager.FOCUSABLE | Field.FOCUSABLE)
{
public void onFocus(int direction)
{
isFocus = true;
super.onFocus(direction);
invalidate();
}
public void onUnfocus()
{
invalidate();
isFocus = false;
super.onUnfocus();
}
public void paint(Graphics g)
{
if(isFocus)
{
hfmrow.setBackground(BackgroundFactory.createSolidBackground(Color.RED));
invalidate();
super.paint(g);
}
else
{
hfmrow.setBackground(BackgroundFactory.createSolidBackground(Color.GREEN));
invalidate();
super.paint(g);
}
}
protected boolean navigationClick(int status, int time)
{
Dialog.alert("You are in hfm"+id);
return true;
}
};
hfmrow.setMargin(0, 10, 0, 10);
hfmrow.add(new NullField(Field.FOCUSABLE));
任何幫助是讚賞.. Thanx提前