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