今天写了Android的数据库的登陆验证的代码,运行后点击登陆没反应,控制台没有错误,日志又错误看不懂,看来自己还是只学了一个皮毛,烦,源码附上

public class MainActivity extends Activity {
    private MyDBHelper dbHelper;
    private EditText username;
    private EditText userpassword;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        
        dbHelper = new MyDBHelper(this,"FeiHuaLin.db",null,1);
    }
    
     //点击注册按钮进入注册页面
    public void logonClicked(View view){
        Intent intent = new Intent(MainActivity.this,Main2Activity.class);
        startActivity(intent);
    }


    //点击登录按钮
    public void loginClicked(View view) {
        username=(EditText)findViewById(R.id.account);
        userpassword=(EditText)findViewById(R.id.password);
        String userName=username.getText().toString();
        String passWord=userpassword.getText().toString();
        if (login(userName,passWord)) {
            Toast.makeText(MainActivity.this, "登陆成功(ZY,111)", Toast.LENGTH_SHORT).show();
        }
        else {
            Toast.makeText(MainActivity.this, "登陆失败", Toast.LENGTH_SHORT).show();
        }
    }

    //验证登录
    public boolean login(String username,String password) {
        SQLiteDatabase db = dbHelper.getWritableDatabase();
        String sql = "select * from User where name=? and password=?";
        Cursor cursor = db.rawQuery(sql, new String[] {username, password});
        if (cursor.moveToFirst()) {
            cursor.close();
            return true;
        }
        return false;
    }
}

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:stretchColumns="1" >

   

                    android:layout_height="wrap_content"
            android:text="Account:" />

                    android:id="@+id/account"
            android:layout_height="wrap_content"
            android:hint="Input your account" />
   

   

                    android:layout_height="wrap_content"
            android:text="Password:" />

                    android:id="@+id/password"
            android:layout_height="wrap_content"
            android:inputType="textPassword" />
   

   

                    android:id="@+id/remember_pass"
            android:layout_height="wrap_content" />

                    android:layout_height="wrap_content"
            android:text="Remember password" />
   

   

                    android:id="@+id/login"
            android:layout_height="wrap_content"
            android:layout_span="2"
            android:text="Login" />
   


05-05 15:06:14.208: E/mqq(3268): waitInit when empty: 
05-05 15:06:14.208: E/mqq(3268): java.lang.RuntimeException: 
05-05 15:06:14.208: E/mqq(3268):     at mqq.app.MobileQQ.waitAppRuntime(MobileQQ.java:810)
05-05 15:06:14.208: E/mqq(3268):     at com.tencent.common.app.BaseApplicationImpl.getRuntime(ProGuard:198)
05-05 15:06:14.208: E/mqq(3268):     at com.tencent.mobileqq.app.DeviceProfileManager.a(ProGuard:284)
05-05 15:06:14.208: E/mqq(3268):     at com.tencent.mobileqq.statistics.battery.BatteryStatsImpl.a(ProGuard:223)
05-05 15:06:14.208: E/mqq(3268):     at com.tencent.mobileqq.statistics.battery.BatteryStatsImpl.a(ProGuard:154)
05-05 15:06:14.208: E/mqq(3268):     at amky.run(ProGuard:85)
05-05 15:06:14.208: E/mqq(3268):     at mqq.os.MqqHandler.handleCallback(MqqHandler.java:337)
05-05 15:06:14.208: E/mqq(3268):     at mqq.os.MqqHandler.dispatchMessage(MqqHandler.java:97)
05-05 15:06:14.208: E/mqq(3268):     at mqq.os.MqqHandler$NativeHandler.dispatchMessage(MqqHandler.java:350)
05-05 15:06:14.208: E/mqq(3268):     at android.os.Looper.loop(Looper.java:135)
05-05 15:06:14.208: E/mqq(3268):     at android.os.HandlerThread.run(HandlerThread.java:61)
 

更多相关文章

  1. gradle 2.1构建android出现错误的解决方案
  2. [Android] 调用系统裁切图片的 !!! FAILED BINDER TRANSACTION !
  3. Android(安卓)Studio Generate Signed APK 错误汇总
  4. (android)关于ListFragment使用
  5. 【Android(安卓)开发教程】从Intent返回结果
  6. android实现程序的后台运行 and 完全退出
  7. ubuntu 9.04下ndk安装问题
  8. android error: Apostrophe not preceded 错误解决办法
  9. Android实现点击事件的三种方法

随机推荐

  1. linux_locale的设定中LANG、LC_ALL、LANG
  2. Linux文件权限查看及修改命令chmod
  3. fedora下vim的安装
  4. Centos7 安装部署 Python-3.6.1
  5. 在Linux中使用PAM进行身份验证为什么它可
  6. 删除目录软链接注意事项
  7. linux网卡实现高可用:team链路聚合
  8. Linux网络设备驱动架構學習(三)
  9. 一·创建Linux服务器(基于阿里云)
  10. Linux中动态链接库总结