0

This If Else 不起作用,因此不会指向菜单页面。我想将字符串与EditText输入进行比较,所以我将其更改为字符串。如何比较两个字段中的字符串输入并将它们与我的字符串 IF-Else 循环进行比较并启动意图

package mjour.fyp;

      public class Login extends Activity{

EditText username;
EditText password;
Button login;
String name, pass;
String lname = "mehdi";



public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.userlogin);

     login = (Button) findViewById(R.id.blog);
     username = (EditText) findViewById(R.id.editText1);
     name = username.getText().toString();   
     password = (EditText) findViewById(R.id.editText2);
     pass = password.getText().toString();  

     login.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub

            Intent myintent = new Intent("mjour.fyp.MENU");
            if(name.contentEquals(lname))
            startActivity(myintent);

            return false;

     };});}}
4

1 回答 1

0

您是否在 startActivity() 之后缺少 else ?

于 2012-04-06T01:24:44.510 回答