2011-03-04 8 views
1
void getThisAlert(String Title, Displayable txtagency2) 
{ 
    Alert error = new Alert("", Title, null, AlertType.INFO); 
    error.setTimeout(2000); 
    Display.getDisplay(myProject).setCurrent(error,txtagency2); 
} 

誰かがいくつかのソリューションを提供してくださいますので....私は..大量のデータを検証していますので、彼はいくつかの特定の詳細を満たしていないショーのユーザーの後、その後、私はそれにフォーカスを置きたい...j2meでエラーを表示した後、テキストフィールドにフォーカスを置く方法は?

私はいくつかの他のページに焦点を当てることができます。

答えて

1

DisplayオブジェクトのcallSeriallyメソッドは、Runnableオブジェクトを実装できます。

private class ItemFocusEventHandler implements Runnable 
{ 
    private Item _Item = null; 

    public ItemFocusEventHandler(Item item) 
    { 
      _Item = item; 
    } 

    public void run() 
    { 
      try { Thread.sleep(1000); } 
      catch (Throwable t) { ; } 

      _display.setCurrentItem(_Item); // sets focus to item 
    } 
} 

その後

if (_txtName.getString().length() == 0)) 
{ 
    Alert alert = new Alert(null, "Name ?", null, AlertType.ERROR); 
    alert.setTimeout(2500); 
    _display.setCurrent(alert, this); 
    _display.callSerially(new ItemFocusEventHandler(_txtName)); 
} 

ルーチンデータの検証にこの方法でフォーカスが_txtNameに受け取ることになります。そのハンドラは他のUI要素にも使用できます。

関連する問題