我的Json:-我在微调框的json city_name下显示了。当我选择city_name时,我想将特定的city_id发送到服务器。 示例:-微调器选择city_name是塔那,然后我想发送“ city_id”:3。
“ citydetails”:[{“ city_id”:1,“ city_name”:“孟买”,“ is_active”:1,“ is_delete”:0},{“ city_id”:2,“ city_name”:“孟加拉” ,“ is_active”:1,“ is_delete”:0},{“ city_id”:3,“ city_name”:“ Thane”,“ is_active”:1,“ is_delete”:0},{“ city_id”:4,“ city_name“:”新孟买“,” is_active“:1,” is_delete“:0},{” city_id“:5,” city_name“:” Panvel“,” is_active“:1,” is_delete“:0},{ “ city_id”:6,“ city_name”:“哥印拜陀”,“ is_active”:1,“ is_delete”:0},{“ city_id”:7,“ city_name”:“ Varanasi”,“ is_active”:1,“ is_delete “:0},{” city_id“:8,” city_name“:”莫卧儿王朝“,” is_active“:1,” is_delete“:0},{” city_id“:9,” city_name“:”阿拉哈巴德“,” is_active“:1,” is_delete“:0},{” city_id“:10,” city_name“:” Patna“,” is_active“:1,” is_delete“:0},{” city_id“:11,” city_name“ :“ Jamshedpur”,“ is_active”:1,“ is_delete”:0},{“ city_id”:12,“ city_name”:“加尔各答”,“ is_active”:1,“ is_delete”:0},{“ city_id” :13,“ city_name”:“浦那”,“ is_active”:1,“ is_delete”:0},{“ city_id”:14,“ city_name”:“ Lucknow”,“ is_active”:1,“ is_delete”:0 },{“ city_id”:15,“ city_name”:“ Kalyan”,“ is_active”:1,“ is_delete”:0},{“ city _id“:16,” city_name“:” Dombivli“,” is_active“:1,” is_delete“:0},{” city_id“:17,” city_name“:” Virar“,” is_active“:1,” is_delete“ :0},{“ city_id”:18,“ city_name”:“ Mira Bhayandar”,“ is_active”:1,“ is_delete”:0},{“ city_id”:19,“ city_name”:“ Ulhasnagar”,“ is_active “:1,” is_delete“:0}]}
spinner =(Spinner)findViewById(R.id.city);
adapter = new ArrayAdapter<String>(this,R.layout.support_simple_spinner_dropdown_item,cityList);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});