在我的应用程序中,我试图从过滤器列表(自动完成字段)中提取值。在该字段中,我有 [ID, Name] ex [j342234, A,S]。我可以通过这样做来检索整个标准
Object Filterlistresult = fliterList.getCriteria();
但现在我只想从该字段中获取提取 ID 部分。有任何想法吗?
先感谢您。
// here I get the values from a web server and insert them to the work Vector
public void parseJSONResponceInWB(String jsonInStrFormat) {
try {
JSONObject json = new JSONObject(jsonInStrFormat);
JSONArray jArray = json.getJSONArray("transport");
for (int i = 1; i < jArray.length(); i++) {
JSONObject j = jArray.getJSONObject(i);
ID = j.getString("ID");
Name = j.getString("Name");
WBenchVector.addElement(ID + " " + Name);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
// adding the values to the filter list
private void RequestAutoComplete() {
String[] returnValues = new String[WBenchVector.size()];
System.out.print(returnValues);
for (int i = 0; i < WBenchVector.size(); i++) {
returnValues[i] = (String) WBenchVector.elementAt(i);
}
autoCompleteField(returnValues);
}
// creating the filter list field
private void autoCompleteField(String[] returnValues) {
filterLst = new BasicFilteredList();
filterLst.addDataSet(ID, returnValues, "",
BasicFilteredList.COMPARISON_IGNORE_CASE);
autoFld.setFilteredList(filterLst);
}
最后我得到了用户使用这个选择的内容
AutoFieldCriteria = filterLst.getCriteria();