![]() |
|
| Programación y Desarrollo para Android Subforo exclusivo para temas de programación de software para PDAs y desarrollo de aplicaciones, interfaces, etc bajo Android |
«
Tema Anterior
|
Siguiente tema
»
|
|
Herramientas |
|
#1
|
||||
|
||||
|
Problema con OnClickListener.onClick
Hola a todos!
Estoy intentando asociar unas acciones a unos botones con OnClickListener en el siguiente código: [PHP]package org.example.appJuegosBeber; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; public class AppJuegosBeberActivity extends Activity implements View.OnClickListener { @override public void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); View juego1_button = findViewById (R.id.juego1_button); juego1_button.setOnClickListener(this); View juego2_button = findViewById (R.id.juego2_button); juego2_button.setOnClickListener(this); View about_button = findViewById (R.id.about_button); about_button.setOnClickListener(this); View exit_button = findViewById (R.id.exit_button); exit_button.setOnClickListener(this); } public void onClick View (v) { switch (v.getId()) { case R.id.about_button: Intent i = new Intent (this, about.class); startActivity(i); break; case R.id.juego1_button: Intent j = new Intent (this, about.class); startActivity(j); break; case R.id.juego2_button: Intent k = new Intent (this, about.class); startActivity(k); break; case R.id.exit_button: finish(); break; } } }[/PHP] Pero btengo los siguientes errores: [PHP]The type AppJuegosBeberActivity must implement the inherited abstract method View.OnClickListener.onClick(View) void is an invalid type for the variable onClick[/PHP] ¿Alguien sabe cómo solucionar estos errores? |
|
|
|
#2
|
|
public void onClick View (v)
Cambia eso por esto: public void onClick (View v) |
| Gracias de parte de: | ||
|
#3
|
||||
|
||||
|
Eso era, ha funcionado! Gracias RubenGM85!
|
| Respuesta |
Estás aquí
|
||||||
|
||||||
«
Tema Anterior
|
Siguiente tema
»
|
|
Hora actual: 00:53:31 (GMT +1)
HTCMania: líderes desde el 2007





