[英]how to get id of selected item in autocompletetextview in android
[英]Android Get Id of Value in AutoCompleteTextView
我正在使用帶有值及其ID的xml數組。我想在用戶選擇它后獲取值的ID。請告訴我如何獲得它?
<string-array name="medicine">
<item id="21058">ALPHA LIPOIC ACID</item>
<item id="19699">B 50 VITAMIN</item>
<item id="19470">B100 ULTRA 50S</item>
</string-array>
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.select_dialog_item, getResources().getStringArray(R.array.medicine));
AutoCompleteTextView actv= (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
actv.setOnClickListener(this);
actv.setThreshold(1);
actv.setAdapter(adapter);
我自己找到了答案。 我做了一個模型ArrayList
,我給你說ArrayList
到AutoCompleteTextView Adapter
,然后在OnClick
的事件AutoCompleteTextView
給我確切的ID和值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.