gpt4 book ai didi

android - 无法检索微调器的值

转载 作者:搜寻专家 更新时间:2023-11-01 09:31:41 24 4
gpt4 key购买 nike

我正在为我使用隐藏字段值的应用程序实现一个自定义微调器。它正在工作,但是当我再次更新时,第一次保存的项目没有显示在微调器上,我需要它会显示在微调器上。谢谢下面是我的代码。

    final MyData items[] = new MyData[25];
items[14] = new MyData("5ft 1in","154");
items[15] = new MyData("5ft 2in","157");
items[16] = new MyData("5ft 3in","160");
items[17] = new MyData("5ft 4in","162");
items[18] = new MyData("5ft 5in","165");
items[19] = new MyData("5ft 6in","167");
items[20] = new MyData("5ft 7in","170");
items[21] = new MyData("5ft 8in","172");
items[22] = new MyData("5ft 9in","175" );
items[23] = new MyData("5ft 10in","177");
items[24] = new MyData("5ft 11in","180");
items[25] = new MyData("5ft 12in","182");
items[26] = new MyData("6ft 1in","185");
items[27] = new MyData("6ft 2in","187");
items[28] = new MyData("6ft 3in","190");
items[29] = new MyData("6ft 4in","193");
items[30] = new MyData("6ft 5in","195");
items[31] = new MyData("6ft 6in","198");
items[32] = new MyData("6ft 7in","201");
items[33] = new MyData("6ft 8in","203");
items[34] = new MyData("6ft 9in","206");
items[35] = new MyData("6ft 10in","208");
items[36] = new MyData("6ft 11in","211");
items[37] = new MyData("6ft 12in","213");
items[38] = new MyData("Above 7ft","217");
ArrayAdapter<MyData> adapter = new ArrayAdapter<MyData>(this, android.R.layout.simple_spinner_item, items );
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

spinHeight1.setAdapter(adapter);
for(int i=0; i < adapter.getCount(); i++) {
if (partnerHeight1.trim().equalsIgnoreCase(adapter.getItem(i).toString())) {
spinHeight1.setSelection(i);
break;
}
}

spinHeight1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
MyData d = items[i];
heightFrom=d.getValue();
}

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

}
});

最佳答案

试试这个方法

 spinHeight1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

heightFrom=spinHeight1.getSelectedItem().toString();
}

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

}
});

关于android - 无法检索微调器的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46680439/

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