1
我在GUI Designer中創建了一個多列表。我正在設置模型如下如何讓imagedownloadservice在codenameone中使用multilist組件?
@Override
protected boolean initListModelMultiIssueList(List cmp) {
fetchIssues(cmp);
if (issueVector != null) {
cmp.setModel(new DefaultListModel(issueVector));
System.out.println(cmp);
}
return true;
}
void fetchIssues(List c){
//fetch issues based on the searchquery hash
//first thing is to create the query from the hash
System.out.println("Starting to fetch results");
try{
java.util.List<ServiceRequest> serviceRequests = ServiceRequest.getServiceRequests(formQuery(searchQuery),true);
//we need to now populate the issueVector
//with the data
System.out.println(serviceRequests.toString());
if (issueVector != null) {
issueVector.clear();
} else {
issueVector = new Vector();
}
int index = 0;
for (ServiceRequest serviceRequest : serviceRequests) {
Hashtable hIssue = new Hashtable();
hIssue.put("id",serviceRequest.getHref());
//System.out.println(hIssue);
ImageDownloadService.createImageToStorage(serviceRequest.getRequestPictureURL().toString(),
c, index, "icon",
"service-icon-"+ index ,null);
//hIssue.put("icon", serviceRequest.getRequestPictureURL().toString());
//System.out.println(hIssue);
//reverse geocode the location
Double x = new Double(0.0);
x=new Double(serviceRequest.getRequestLocationLatitude());
Double y = new Double(serviceRequest.getRequestLocationLongitude());
String location=reverseGeocode(x, y);
hIssue.put("location", location);
//System.out.println(hIssue);
Service service = serviceRequest.loadService();
hIssue.put("service", serviceRequest.loadService().getName().toString());
hIssue.put("reportedOn",serviceRequest.getCreatedAt().toString());
//System.out.println("Final hIssue" + hIssue.toString());
issueVector.add(hIssue);
index=index+1;
System.out.println(issueVector);
}
}catch (Exception e){
System.out.println("Error loading search results");
System.out.println(e);
}
}
多列表GUI設計中的圖標已被設置爲相應的屬性。 ImageDownloadService不會下載圖像文件,但它不會按預期方式顯示在列表中。我究竟做錯了什麼?
OK。如果我理解正確,我應該創建模型並設置到列表中。所以在我的代碼中,我應該在設置模型之後調用fetchIssues(),而不是之前。我會盡力。 – user1622343 2013-03-15 13:58:43
嘗試過但不起作用。理解是首先建立列表並設置模型和顯示。然後再次遍歷列表並使用imagedownloadservice進行更新。要求該圖標已在列表中定義,並使用imagedownloadservice將替換的某個佔位符值。我會盡力並保持清醒,看看我能否實現。 – user1622343 2013-03-15 14:50:32
什麼不起作用?你在調試器中運行它嗎?你有例外嗎?你看過演示,如Facebook演示中使用了這個嗎? – 2013-03-17 09:27:12