I am new to Android app development. I am using the sample form provided at http://developer.android.com/resources/tutorials/views/hello-formstuff.html . In this I used an example of a custom button.
My code is as follows:
package com.example.helloformstuff;
import android.app.Activity;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class HelloFormStuff extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(HelloFormStuff.this, "Beep Bop", Toast.LENGTH_SHORT).show();
}
});
}
}
The following error is shown:
The type new DialogInterface.OnClickListener(){} must implement the inherited
abstract method DialogInterface.OnClickListener.onClick(DialogInterface, int)
- The method setOnClickListener(View.OnClickListener) in the type View is not
applicable for the arguments (new DialogInterface.OnClickListener(){})
I can not understand the reason for this error.
Please help me with this.
thank
Pankai
source
share