我有一个使用微调器的表单,我使用翻新2从数据库中获取的数据微调器,我有一个字段id_employee和employee_name,我想显示的是employee_name但id_fish保存在数据库中。
我成功在android Spinner中显示了employee_name,但是当我想将表单保存到数据库中时,id_employee,如何在旋转器中显示的employee_name示例中保存id_employee:
return json_format.Parse(text=json.dumps(response), message=instanceType, ignore_unknown_fields=False)
MySpinner:
<select>
<option value="001">Brad Smith</option>
<option value="002">Wanda</option>
<option value="003">John Doe</option>
<select>
这是微调器SetOnclickListener:
private initSpinner()
{
List<DataEmployee> dataEmployee= response.body().getData();
List<String> idEmployee = new ArrayList<String>();
List<String> employeeName = new ArrayList<String>();
for (int i = 0; i < dataEmployee.size(); i++){
idEmployee.add(dataFish.get(i).getId_employee());
employeeName.add(dataEmployee.get(i).getEmployee_name());
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(LelangActivity.this,
android.R.layout.simple_spinner_item, employeeName);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerEmployee.setAdapter(adapter);
}
答案 0 :(得分:0)
//try this
spinnerFish.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String Fishname= datafish.get(i).getId_employee();
}
});