我正在尝试登录我的网站,需要弄清楚如何将单选按钮选项转换为字符串,然后将其转换为 EditText。
public class HttpLogin extends Activity {
private Button login;
private EditText company, username, password;
private int radioCheckedId;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
login = (Button) findViewById(R.id.button1);
RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radioCompany);
radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(RadioGroup group, int checkedId) {
radioCheckedId = checkedId;
if(radioCheckedId==1){
company=R.string.a_e;
}
if(radioCheckedId==2){
company=R.string.stat_o;
}
else{
Toast.makeText(getApplicationContext(), "Please choose a company.",
Toast.LENGTH_LONG).show();
}
}
});
username = (EditText) findViewById(R.id.editText1);
password = (EditText) findViewById(R.id.editText2);
login.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String mCompany = company.getText().toString();
String mUsername = username.getText().toString();
String mPassword = password.getText().toString();
tryLogin(mCompany, mUsername, mPassword);
}
});
}