哪能整數年齡轉換爲字符串,這樣我可以得到的文本字段中的值set.Age爲java.lang.String
代碼
public void onSignUpClick(View v)
{
if (v.getId()==R.id.bregister);
{
EditText fname = (EditText)findViewById(R.id.fname);
EditText lname = (EditText)findViewById(R.id.lname);
EditText age = (EditText)findViewById(R.id.age);
EditText gender = (EditText)findViewById(R.id.gender);
EditText uname = (EditText)findViewById(R.id.uname);
EditText pass1 = (EditText)findViewById(R.id.pass1);
EditText pass2 = (EditText)findViewById(R.id.pass2);
String fnamestr = fname.getText().toString();
String lnamestr = lname.getText().toString();
String agestr = age.getText().toString();
String genderstr = gender.getText().toString();
String unamestr = uname.getText().toString();
String pass1str = pass1.getText().toString();
String pass2str = pass2.getText().toString();
if(!pass1str.equals(pass2str))
{
//popup message appears
Toast pass = Toast.makeText(signup.this,"Password don't match!", Toast.LENGTH_SHORT);
pass.show();
}
else
{
//insert the details in the database
contact c = new contact();
c.setFname(fnamestr);
c.setLname(lnamestr);
c.setAge(agestr);
c.setGender(genderstr);
c.setUname(unamestr);
c.setPass(pass1str);
'字符串結果=將String.valueOf(intVar)'或'字符串結果= intVar + 「」;' – Piyush
@Piyush沒有'intVar',一切是String –
呀!我知道 。我剛剛根據她的問題提供了一個提示或建議! – Piyush