I am creating an Android application and after my last question ( Android application cannot open the web link ), I get this syntax error in Eclipse
Cannot instantiate the type View.OnClickListener
My code is as follows:
package com.example.ldsm3;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.method.MovementMethod;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Finished extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_finished);
TextView tv = (TextView) findViewById(R.id.textView2);
tv.setText(Misc.correct + "/" + Misc.total);
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new Button.OnClickListener());
}
public void onClick(View v)
{
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://whackamole.ajav-games.tk"));
startActivity(browserIntent);
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.finished, menu);
return true;
}
}
How to fix it? I know that this is probably a simple Java error, but I have not used Java before, and please explain them by reference to Java syntax, terms, etc.
source
share