如何创建多级用户登录-Android Studio

时间:2018-11-22 16:37:14

标签: javascript android

我正在尝试创建2个用户类型。一个是老师,另一个是学生。

单击单选按钮数据时,它将保存到数据库中,当学生登录时,它将进入学生班级。另一方面,教师登录将转到教师班。

这是我在寄存器类中所做的,我想保存在数据库中。

public void RadioButtonClicked(View view) {
   boolean checked = ((RadioButton) view).isChecked();
   switch(view.getId()) {
      case R.id.radio_button1:
         if (checked)
         db.insert("","","","","","","Student");
         break;
      case R.id.radio_button2:
         if (checked)
         db.insert("","","","","","","Teacher");
         break;
   }
}

*登录

login.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
      String username = user.getText().toString();
      String password = passw.getText().toString();
      boolean chkemailpass = db.emailpassword(username,password);
      if(chkemailpass==true){
         Toast.makeText(getApplicationContext(),"Successfully Login",Toast.LENGTH_SHORT).show();
         startActivity(new Intent(MainActivity.this, Home.class));
      }else{
      Toast.makeText(getApplicationContext(),"Wrong Username or Password",Toast.LENGTH_SHORT).show();
      }
   }
});

0 个答案:

没有答案