Soy un novato en el desarrollo de aplicaciones de Android. Estoy usando el ejemplo Form Stuff dado en http://developer.android.com/resources/tutorials/views/hello-formstuff.html. En esto he usado el ejemplo de botón personalizado.Ejemplo de botón personalizado que no funciona
Mi código es la siguiente:
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 {
/** Called when the activity is first created. */
@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) {
// Perform action on clicks
Toast.makeText(HelloFormStuff.this, "Beep Bop", Toast.LENGTH_SHORT).show();
}
});
}
}
Su proyección siguiente error:
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(){})
no soy capaz de averiguar la razón de tal error.
Por favor, ayúdenme en esto.
Gracias
Pankaj
¿Sabes por qué esto está escrito de esta manera? ¿Por qué no puede haber un solo oyente? – user219882