0
- 用戶類型2個字母在自動完成文本框中
- 這2個字母得到保存,並在Web服務方法使用,以 檢索誰開始的所有用戶與2個字母
- XML結果得到恢復,並得到解析,我們獲取的用戶名+ id和 保存在不同的ArrayList
- 結果從第一個名稱的ArrayList在下拉列表中得到看跌期權每一個(自動完成之一)
- Th E用戶從下拉列表項的項目
- 我需要顯示在下拉列表中的名稱,但是,當用戶選擇一個名字,該用戶ID應選擇並保存爲字符串以便用於其他查詢。顯示值,但選擇從ID下拉列表
的問題是:如何顯示的名字,但選擇ID爲名稱
AutoCompleteTextView assigneeInput;
assigneeInput=(AutoCompleteTextView)
findViewById(id.editassignee);
assigneeInput.addTextChangedListener(new
TextWatcher() {
@Override
public void onTextChanged (CharSequence s,int start, int before, int count){
getContactsForAssignee();
}
@Override
public void beforeTextChanged (CharSequence s,int start, int count, int after){
}
@Override
public void afterTextChanged (Editable s){
}
}
);
//Textwatcher for assignee input -end
}
//Method to get Contacts for the assignee autocomplete - Start
public void getContactsForAssignee() {
//webservice call method
}
//Method to get Contacts for the assignee autocomplete - End
public void receiveResults10(String result10) {
try {
//Dom parsing set up
List<String> valSetOne = new ArrayList<String>();
List<String> valSetTwo = new ArrayList<String>();
ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < nodesUDSObjectList.getLength(); i++) {
Element elementUDSObject = (Element) nodesUDSObjectList.item(i);
NodeList nodesAttributeList = elementUDSObject.getElementsByTagName("Attribute");
HashMap<String, String> mapp = new HashMap<String, String>();
for (int iA = 0; iA < nodesAttributeList.getLength(); iA++) {
Element elementAttribute = (Element) nodesAttributeList.item(iA);
//You have attribute(iA)
NodeList AttrNameElementList = (NodeList) elementAttribute.getElementsByTagName("AttrName");
String nameValue = getCharacterDataFromElement((Element) (AttrNameElementList.item(0)));
System.out.println("name" + nameValue);
NodeList AttrValueElementList = (NodeList) elementAttribute.getElementsByTagName("AttrValue");
String valueValue = getCharacterDataFromElement((Element) (AttrValueElementList.item(0)));
if (nameValue.equals("name")) {
valSetOne.add(valueValue);
mapp.put(COMBO_NAME, valueValue);
}
if (nameValue.equals("id")) {
valSetTwo.add(valueValue);
mapp.put(PERSISTENT_ID, valueValue);
}
}
menuItems.add(mapp);
}
AutoCompleteTextView editAssignee;
ArrayAdapter<String> adapter;
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, valSetOne);
editAssignee = (AutoCompleteTextView) findViewById(R.id.editassignee);
editAssignee.setAdapter(adapter);
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getCharacterDataFromElement(Element e) {
}
//Beginning of method to actually save the ticket executed on click of the "save" button
public void SaveThisIncident(View v) {
AutoCompleteTextView editAssigneeInput = (AutoCompleteTextView) findViewById(R.id.editassignee); //receiving the users input for assignee
String thisIsAssignee = editAssigneeInput.getText().toString();
}
我怎麼能做到這一點,你讓我看看怎麼樣?非常感謝 – Mash 2014-09-19 05:54:57
如果我將ArrayAdapter更改爲BaseAdapter,我得到的錯誤「BaseAdapter類型不是通用的;它不能用參數參數化」如果你知道如何解決我的問題plzzz幫助我,我真的需要它緊急工作 –
Mash
2014-09-19 07:54:52
你可以請參閱Baseadapter用法的答案http://stackoverflow.com/a/16335923/1677824 – Akhil 2014-09-19 12:44:31