2016-07-25 90 views
1

當我輸入以'W'開頭的位置時,下面列出了相關位置。但是,如果我刪除已經鍵入的位置,然後鍵入以'L'開頭的另一個位置,那麼該列表將首先顯示先前列出的舊位置選項(以'W'開頭的位置),則與新位置相關的選項爲上市。動態自動完成

因此,自動完成列表顯示以'W'開頭的位置,然後顯示以'L'開頭的位置。 我也試過把options.removeAll();作爲過濾方法的第一個陳述。

AutoCompleteTextField ac = new AutoCompleteTextField(options) { 
protected boolean filter(String add) { 
      options.removeAll(); 
      if(add.length() == 0) { 


       return false; 
      } 
      String[] l = searchLocations(add); 
      if(l == null || l.length == 0) { 
       return false; 
      } 


      for(String s : l) { 
       options.addItem(s); 
      } 
      return true; 
     } 
    }; 
    //ac.setMinimumElementsShownInPopup(1); 

    ac.setMinimumLength(1); 
    Container c = stateMachine.findContainer(form); 
    AutoCompleteTextField oldac = (AutoCompleteTextField) stateMachine.findAddress(c); 
    c.replace(oldac, ac, null); 

有沒有辦法糾正這個問題?

謝謝!

回答

0

退房this live sample,這個問題在這裏不會發生,所以我猜測問題與預先存在的結果是相關的,你修改模型的方式。

+0

謝謝..現在它的工作正常! – Durga