嘿伙计我有一个关于如何从微调器中选择性别的问题,在选择性别后我想将性别结果存储到性别变量中,所以,你能帮我解决这个问题,
提前致谢
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="arr_gender">
<item>Male</item>
<item>Female</item>
</string-array>
并且在选择性别&gt;&gt;之后,我想要存储此变量字符串性别;
private void initGenderData() {
ArrayAdapter adater_gender = ArrayAdapter.createFromResource(
Question_page.this, R.array.arr_gender,
android.R.layout.simple_spinner_item);
adater_gender.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
this.sp_gender.setAdapter(adater_gender);
sp_gender.isClickable();
}
and I don't know how to deal with this spinner now give me some example thanks
答案 0 :(得分:0)
到目前为止,一切都是正确的,现在尝试这样来存储性别:
String gender = sp_gender.getSelectedItem().toString();
答案 1 :(得分:0)
Hy,试试这个......
sp_gender.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
String gender = sp_gender.getSelectedItem().toString();
}
}