AutoCompleteTextField는 TextField에서 백 스페이스를 시작할 때까지 의도 한대로 작동하는 것 같습니다. 차이점이 무엇인지 모르겠지만 "123 M"과 같은 것을 입력하면 "123 M"으로 시작하는 값을 얻습니다. 백 스페이스를 사용하여 필드에 "123"을 남기는 M을 삭제하면 목록이 변경되지만 목록의 맨 위로 스크롤되지는 않습니다.AutoCompleteTextField 목록이 항상 맨 위로 스크롤되지는 않습니까?
시뮬레이터에서 모든 것이 잘 작동하며 내 iPhone에서 디버그 빌드를 실행할 때이 문제가 발생합니다.
편집 : 그래서 이것은 백 스페이스 할 때 일어나는 것처럼 보이지 않습니다. 이 이미지는 키로 주소 키를 입력 할 때의 결과를 보여줍니다. 목록을 볼 수 없거나 잘리는 그림에서는 목록을 아래로 드래그하여 올바르게 표시 할 수 있습니다. 나는 안드로이드 장치에서 이것을 시도하지 않았습니다.
EDIT2 :
public class CodenameOneTest {
private Form current;
private Resources theme;
private WaitingClass w;
private String[] properties = {"1 MAIN STREET", "123 E MAIN STREET", "12 EASTER ROAD", "24 MAIN STREET"};
public void init(Object context) {
theme = UIManager.initFirstTheme("/theme");
// Enable Toolbar on all Forms by default
Toolbar.setGlobalToolbar(true);
}
public void start() {
if(current != null) {
current.show();
return;
}
Form form = new Form("AutoCompleteTextField");
form.setLayout(new BorderLayout());
final DefaultListModel<String> options = new DefaultListModel<>();
AutoCompleteTextField ac = new AutoCompleteTextField(options) {
protected boolean filter(String text) {
if(text.length() == 0) {
options.removeAll();
return false;
}
String[] l = searchLocations(text);
if(l == null || l.length == 0) {
return false;
}
options.removeAll();
for(String s : l) {
options.addItem(s);
}
return true;
};
};
Container container = new Container(BoxLayout.y());
container.setScrollableY(true); // If you comment this out then the field works fine
container.add(ac);
form.addComponent(BorderLayout.CENTER, container);
form.show();
}
String[] searchLocations(String text) {
try {
if(text.length() > 0) {
if(w != null) {
w.actionPerformed(null);
}
w = new WaitingClass();
String[] properties = getProperties(text);
if(Display.getInstance().isEdt()) {
Display.getInstance().invokeAndBlock(w);
}
else {
w.run();
}
return properties;
}
}
catch(Exception e) {
Log.e(e);
}
return null;
}
private String[] getProperties(String text) {
List<String> returnList = new ArrayList<>();
List<String> propertyList = Arrays.asList(properties);
for(String property : propertyList) {
if(property.startsWith(text)) {
returnList.add(property);
}
}
w.actionPerformed(null);
return returnList.toArray(new String[returnList.size()]);
}
class WaitingClass implements Runnable, ActionListener<ActionEvent> {
private boolean finishedWaiting;
public void run() {
while(!finishedWaiting) {
try {
Thread.sleep(30);
}
catch(InterruptedException ex) {
ex.printStackTrace();
}
}
}
public void actionPerformed(ActionEvent e) {
finishedWaiting = true;
return;
}
}
public void stop() {
current = Display.getInstance().getCurrent();
if(current instanceof Dialog) {
((Dialog)current).dispose();
current = Display.getInstance().getCurrent();
}
}
public void destroy() {
}
}
Android/다른 기기에서 제대로 작동합니까? 어떻게 보이는지 알 수있는 스크린 샷을 제공 할 수 있습니까? –
@ShaiAlmog 스크린 샷을 추가했습니다! – Tommo
나는 스티브에게 이것을 시도하고 재현하도록 요청했는데 우리는 할 수 없었다. 문제를 재현하는 테스트 케이스를 게시 할 수 있습니까? –