你能告诉我这里有什么错误吗?它告诉我吐司制作中的“性别”必须设置为最终但当我这样做时,if语句抱怨它不应该是最终的
@Override
protected void onCreate(Bundle savedInstanceState) {
String gender = null;
Toast.makeText(this, R.string.ok, Toast.LENGTH_LONG).show();
super.onCreate(savedInstanceState);
setContentView(R.layout.createprofile);
RadioButton rb_male = (RadioButton) findViewById(R.id.maleradiobutton);
String male=rb_male.getText().toString();
RadioButton rb_female = (RadioButton) findViewById(R.id.femaleradiobutton);
String female=rb_male.getText().toString();
if(rb_male.isChecked()) { gender = "male";}
if(rb_female.isChecked()){ gender = "female";}
Button checkgender = (Button) findViewById(R.id.gendercheck);
checkgender.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(ProfileActivity.this, gender.toString(), Toast.LENGTH_LONG);
}
});
}
}