如何在Java中修复此错误?

时间:2022-11-07 18:58:03

I have started learning Android Application development for 15 days. I am newbie.Please help me to solve following error.

我已经开始学习Android应用程序开发15天了。我是新手。请帮我解决以下错误。

Error:Variable DeclaratorID expected after this token

location: Intent syntax

location:Intent语法

code:

public class MainActivity extends Activity {
    Button _loginBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
        _loginBtn = (Button) findViewById(R.id.btn_login);

        _loginBtn.setOnClickListener(new View.OnClickListener(){

              @Override
              public void onClick(View v);

              Intent in1 = new Intent(MainActivity.this, TweetList.class);
              startActivity(in1);

             }
        );
     }
} 

enter image description here

在此处输入图像描述

1 个解决方案

#1


3  

You forgot to open the onClick method with {.

你忘了用{打开onClick方法。

It should be :

它应该是 :

          @Override
          public void onClick(View v) {
              Intent in1 = new Intent(MainActivity.this, TweetList.class);
              startActivity(in1);
         }

#1


3  

You forgot to open the onClick method with {.

你忘了用{打开onClick方法。

It should be :

它应该是 :

          @Override
          public void onClick(View v) {
              Intent in1 = new Intent(MainActivity.this, TweetList.class);
              startActivity(in1);
         }