-6
public void onClick(View v) {
    String uname=tv1.getText().toString();
    String pass=tv2.getText().toString();
    //String copmare=uname.concat(pass);

    Cursor cur = db.query("accountTable",    // Where are we looking?
        new String[]{ "colProject" },    // What do we want back?
        "colName = ? AND colPass = ?",   // What are we matching?
        new String[]{ uname, pass },     // What to put in the "holes"?
        null, null, null);               // Everything else default...

    if (cur != null) {
        cur.moveToNext();
    }
    return;

    Intent i = new Intent(FirstAssignmentActivity.this,success.class);
    i.putExtra("v1",   cur.getString(0));
    startActivity(i);

}

为什么我有无法访问的代码?

4

2 回答 2

2

你写return ;了,所以控制会在那个时候退出函数,而不是到达函数的最后 3 行(Intent i等)

于 2011-09-05T05:36:53.013 回答
0

您正在从该方法返回。之后的代码都不会执行。

if (cur != null) {
    cur.moveToNext();
}
return;  // AFTER THIS NOTHING WILL EXECUTE 
于 2011-09-05T05:38:28.993 回答