我正在使用MaterialBetterSpinner 如何获取所选项目文本或位置?
每次我得到同样的旗帜 我该怎么办?
我想将此标志发送到服务器并根据它获得响应
每次发送flag_check=1;
ArrayList<String> morning_evening_flag = new ArrayList <String>();
morning_evening_flag.add("Morning");
morning_evening_flag.add("Evening");
ArrayAdapter<String> spinnerAdapter1 = new ArrayAdapter<String>(context,R.layout.spinner_row, morning_evening_flag);
final MaterialBetterSpinner spinner1 = (MaterialBetterSpinner) dialogView.findViewById(R.id.spinner1);
spinner1.setAdapter(spinnerAdapter1);
int morning_pasition=spinnerAdapter1.getPosition("Morning");
int Evening_pasition=spinnerAdapter1.getPosition("Evening");
Log.e("morning_pasition", morning_pasition+"");
Log.e("Evening_pasition", Evening_pasition+"");
final int flag_check;
if("Morning".equals("0"))
{
flag_check=0;
}
else
flag_check=1;
答案 0 :(得分:0)
您需要将onClickListener设置为微调器:
spinnerName.setOnItemSelectedListener(本);
现在实现onItemselected方法
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
// You will get the position and selected item here
}