2012-05-08 52 views
1
@Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 


     txtUserName=(EditText)this.findViewById(R.id.txtUname); 
     txtPassword=(EditText)this.findViewById(R.id.txtPwd); 
     btnLogin=(Button)this.findViewById(R.id.btnLogin); 
     btnLogin=(Button)this.findViewById(R.id.btnLogin); 
     btnLogin.setOnClickListener(new OnClickListener() { 

      Button next = (Button) findViewById(R.id.Button01); 
    error1: next.setOnClickListener(new View.OnClickListener() { 

      public void onClick(View view) { 
      Intent myIntent = new Intent(view.getContext(), AddName.class); 
      startActivityForResult(myIntent, 0); 
     }} 
    error2: ) 

     }; 

    if((txtUserName.getText().toString()).equals(txtPassword.getText().toString())){ 
      Toast.makeText(LoginappActivity.this, "Login Successful",Toast.LENGTH_LONG).show(); 
      } else{ 
      Toast.makeText(LoginappActivity.this, "Invalid Login",Toast.LENGTH_LONG).show(); 
      } 
      } 

    } 

我已經創建了一個登錄應用程序,從一個意圖改變到另一個意圖。其他的.java工作正常android登錄應用程序之間切換兩個意圖

  • ERROR1:上標記語法錯誤,AnnotationName有望代替

  • 誤差2:多個標記在該行
    - Syntax error, insert "EnumBody" to complete EnumDeclaration
    - Syntax error, insert "enum Identifier" to complete EnumHeaderName
    - Syntax error, insert ")" to complete Expression
    - Syntax error, insert "}" to complete ClassBody

+0

你可以張貼線35和41,或包含它們更大的代碼片段? –

+2

請仔細查看代碼並修復縮進並製作錯誤的代碼框。使它更容易閱讀。 – dutt

+0

行:35 next.setOnClickListener(新View.OnClickListener(){ – Abhinai

回答

1

它必須像:

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    txtUserName = (EditText) this.findViewById(R.id.txtUname); 
    txtPassword = (EditText) this.findViewById(R.id.txtPwd); 
    Button btnLogin = (Button) this.findViewById(R.id.btnLogin); 

    btnLogin.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      // TODO Auto-generated method stub 
      if ((txtUserName.getText().toString()).equals(txtPassword.getText() 
      .toString())) { 
     Toast.makeText(DelActivity.this, "Login Successful", 
       Toast.LENGTH_LONG).show(); 
    } else { 
     Toast.makeText(DelActivity.this, "Invalid Login", 
       Toast.LENGTH_LONG).show(); 
    } 
     } 
    }); 

    Button next = (Button) findViewById(R.id.button1); 
    next.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View view) { 
      //Intent myIntent = new Intent(view.getContext(), AddName.class); 
      //startActivityForResult(myIntent, 0); 
     } 
    }); 

} 
+0

同時運行此應用程序運行良好將第2頁,但它不是顯示登錄是成功的還是無效的請幫助我 – Abhinai

+0

檢查代碼現在 –

3

onClick函數的末尾有一些額外的}}。它應該是:

next.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View view) { 
      Intent myIntent = new Intent(view.getContext(), AddName.class); 
      startActivityForResult(myIntent, 0); 
     } 
}); 

順便說一下,我發現onClickListener在另一個onClickListener中的用法非常混亂。你應該分開它們。

+0

我修改,但他同樣的錯誤在該行繼續多次標記 \t - 語法錯誤,插入「}」來完成ClassBody \t - 語法錯誤,插入「 )」來完成表達 \t - 語法錯誤,插入‘EnumBody’完成EnumDeclaration \t - 語法錯誤,插入‘枚舉標識符’完成 \t EnumHeaderName – Abhinai

相關問題