gpt4 book ai didi

java - autocompletetextview 设置选择不起作用

转载 作者:行者123 更新时间:2023-11-30 06:22:07 43 4
gpt4 key购买 nike

我有两个自动完成 TextView 例如,如果任何人选择自动完成 TextView “HUB ID”位置#3,则另一个自动完成 TextView “HUBName”必须强制位于位置 3即希望它们都处于同一位置

           // HUB Name listener
HubName.setOnItemClickListener(new AdapterView.OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> parent, View arg1, int pos, long id) {
HubName.setSelection(pos);
Log.d("ID Array follow pos","HUB ID in selected");
HubID.setSelection(pos);
HubName.setSelection(pos);

ShltrArray.clear();
ShltrArray.add(Shltr1Array.get(pos).toString());
if (Shltr2Array.get(pos).toString() != "Not")
{
ShltrArray.add(Shltr2Array.get(pos).toString());
}
ShltrAdapt.notifyDataSetChanged();


}

});

HubName.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
HubName.setSelection(position);
HubID.setSelection(position);
}

@Override
public void onNothingSelected(AdapterView<?> parent) {

}
});
HubName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HubName.showDropDown();


Log.d("ID Array follow ID ", Integer.toString(HubID.getListSelection()));
Log.d("ID Array follow Name ", Integer.toString(HubName.getListSelection()));
}
});

最佳答案

将数组列表索引到第一个数组的相同位置,然后在 autocompleteTextView 监听器内然后将文本设置到该位置的解决方案,如下所示

HubName.setOnItemClickListener(new AdapterView.OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> parent, View arg1, int pos, long id) {
HubID.setText(IDArray.get(pos).toString());}

关于java - autocompletetextview 设置选择不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47905089/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com