• 结对项目:日程管理(二)


    登录、注册界面

    主要代码

    注册按钮
    //注册点击
    public void dregi(View view){
    Intent intentlogin = new Intent();
    intentlogin.setClass(SecondActivity.this,MainActivity.class);
    startActivity(intentlogin);

    登录按钮
    //登录点击
    public void dlogin(View view){
    String name=mname.getText().toString();
    String password=mpassword.getText().toString();
    if(name.equals("")||password.equals("")){
    Toast.makeText(this, "帐号或密码不能为空", Toast.LENGTH_LONG).show();
    return;
    }
    BmobQuery query=new BmobQuery();
    query.addWhereEqualTo("name", name);
    query.addWhereEqualTo("password", password);
    query.findObjects(new FindListener() {

            @Override
            public void done(List<user> arg0, BmobException e) {
                // TODO Auto-generated method stub
                if(e==null){
                String gname=arg0.get(0).getName().toString();
                String gpassword=arg0.get(0).getPassword().toString();
                String name=mname.getText().toString();
                String password=mpassword.getText().toString();
                Toast.makeText(SecondActivity.this, gname, Toast.LENGTH_LONG).show();
                if(gname.equals(name)&&gpassword.equals(password))
                {
                    Intent seccess = new Intent();
                    seccess.setClass(SecondActivity.this, ThridActivity.class);
                    startActivity(seccess);
                }
                
                }
                else{
                    Toast.makeText(SecondActivity.this, "帐号或密码有误", Toast.LENGTH_LONG).show();
                }
    

    注册功能的实现:
    //点击注册
    public void zhuce(View view){

        String name=mname.getText().toString();
        String password=mpassword.getText().toString();
        String number=mnumber.getText().toString();
        String verify=mverify.getText().toString();
        if(name.equals("")||password.equals(""))
        {
            Toast.makeText(this, "帐号或密码不能为空", Toast.LENGTH_LONG).show();
            return;
        }
        if(name.length()<6)
        {
            Toast.makeText(this, "帐号小于6位", Toast.LENGTH_LONG).show();
            return;
        }
        if(verify.length()==0)
        {
            Toast.makeText(this, "验证码不能为空", Toast.LENGTH_LONG).show();
            return;
        }
        if(number.length()==0)
        {
            Toast.makeText(this, "手机号不能为空", Toast.LENGTH_LONG).show();
            return;
        }
        if(number.length()!=11)
        {
            Toast.makeText(this, "请输入11位有效号码", Toast.LENGTH_LONG).show();
            return;
        }
        BmobSMS.verifySmsCode(this, number, verify, new VerifySMSCodeListener() {
            
            @Override
            public void done(cn.bmob.sms.exception.BmobException e) {
                // TODO Auto-generated method stub
                if (e == null) {  
                    Toast.makeText(MainActivity.this, "注册成功", Toast.LENGTH_SHORT).show(); 
                  //验证码正确 添加用户信息
                    String name=mname.getText().toString();
                    String password=mpassword.getText().toString();
                    user User=new user();
                    User.setName(name);
                    User.setPassword(password);
                    User.save(new SaveListener<String>() {
    
                        @Override
                        public void done(String arg0, BmobException arg1) {
                            // TODO Auto-generated method stub
                            if(arg1==null){
                                return;
                                
                            }else{
                                return;
                            }
                        }
                        
                    });
                    
                    Intent intent2 = new Intent();
                    intent2.setClass(MainActivity.this, SecondActivity.class);
                    MainActivity.this.startActivity(intent2);
                }  
                else {   
                    Toast.makeText(MainActivity.this, "验证码错误", Toast.LENGTH_SHORT).show();  
                }  
            }
  • 相关阅读:
    (转)C3P0连接池配置和实现详解
    (转)jquery插件Validate的使用
    二叉树和翻转二叉树
    利用@media screen实现网页布局的自适应
    (转)防止SQL注入的五种方法
    java代码规范
    Java泛型-类型擦除
    js中的isNaN()
    (转)sublime 一些常用功能和快捷键
    (转)java中不常见的关键字:strictfp,transient
  • 原文地址:https://www.cnblogs.com/daijiujiu/p/7001505.html
Copyright © 2020-2023  润新知