今天用了一个半小时的时间
边学习边做后台数据注册的
内容,其中学习了如何在后
台获取前台按钮的结果,和
如何获取前台文本输入框的
结果和提示框。详细代码如下
on_user=findViewById(R.id.on_user);
on_password=findViewById(R.id.on_password);
on_juese=findViewById(R.id.on_juese);
on_juese.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
if(i==R.id.student) juese="student";
if(i==R.id.techer) juese="teacehr";
}
});
btn1=findViewById(R.id.haveoning);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(MainActivity.this,Zhuce.class);
startActivity(intent);
}
});
btn2=findViewById(R.id.oning);
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String shuow=on_user.getText().toString()+on_password.getText().toString()+juese;
Toast.makeText(MainActivity.this,shuow,Toast.LENGTH_LONG).show();
}
});
}
id=findViewById(R.id.haveoning_id);标签:总结,findViewById,12,getText,3.7,toString,new,haveoning,id From: https://www.cnblogs.com/2351920019xin/p/17189109.html
name=findViewById(R.id.haveoning_name);
phonenumber=findViewById(R.id.haveoning_phonenumber);
flat=findViewById(R.id.haveoning_flat);
password=findViewById(R.id.haveoning_password);
aginpassword=findViewById(R.id.haveoning_aginpassword);
submit=findViewById(R.id.haveoning_submit);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(!password.getText().toString().equals(aginpassword.getText().toString())){
Toast.makeText(Zhuce.this,"密码不正确!!!",Toast.LENGTH_LONG).show();
}
else{
//kaishizhuce
Sql_one add=new Sql_one();
try {
add.Zhuce(id.getText().toString(),name.getText().toString(),phonenumber.getText().toString(),flat.getText().toString(),password.getText().toString());
} catch (Exception e) {
throw new RuntimeException(e);
}
//jiehsuzhuce
}
}
});