Problemas em ShowAlert

Eu não sei como declarar o ShowAlert para funcionar dentro do meu método. Alguém tem uma luz?

Erro:
The method ShowAlert(…) is undefined for the type new View.OnClickListener(){}.

package br.android.supermercado;

import android.app.Activity;

import android.os.Bundle;
import android.widget.*;
import android.view.*;

public class appSupermercado extends Activity {
	CheckBox chkleite,chkrefri,chkcarne,chkarroz,chkfeijao;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        chkleite = (CheckBox)findViewById(R.item.chkarroz);
        chkrefri = (CheckBox)findViewById(R.item.chkrefri);
        chkcarne = (CheckBox)findViewById(R.item.chkcarne);
        chkarroz = (CheckBox)findViewById(R.item.chkarroz);
        chkfeijao = (CheckBox)findViewById(R.item.chkfeijao);
        
        Button btTotal = (Button)findViewById(R.botao.btCalc);
        btTotal.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				double total=0;
				
				if(chkleite.isChecked())
					total += 5;
				if(chkrefri.isChecked())
					total += 2;
				if(chkcarne.isChecked())
					total += 10;
				if(chkarroz.isChecked())
					total += 2.69;
				if(chkfeijao.isChecked())
					total += 2.30;
				else
					total += 0;
				
				showAlert("Total da Compra: ",0,String.valueOf(total),"OK",false); //ERRO APARECE NESTA LINHA!!!!!
			}
		});
        
    }
}

Olá amigo boa noite, tudo bem?
Tive esse mesmo problema, mas consegui contornar esse problema usando um Toast, como no exemplo abaixo:

bttotal.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			double total = 0;
			
			if(chkarroz.isChecked())
				total+=2.69;
			if(chkleite.isChecked())
				total+=5.00;
			if(chkcarne.isChecked())
				total+=10.00;
			if(chkfeijao.isChecked())
				total+=2.30;
			if(chkcoca.isChecked())
				total+=2.00;
			//showAlert("Valor total da compra",0,String.valueOf(total),"OK",false);
			Toast mostrar = Toast.makeText(getApplicationContext(), "Valor total da compra "+total, Toast.LENGTH_LONG);
			mostrar.show();
		}
	});

Espero ter ajudado!!!

Parece que showAlert está deprecated.

Esse método é de quem?

Como assim de quem? Fiz esta pergunta a muito tempo atrás quando estava iniciando em Android. :slight_smile:

Foi isso que você perguntou Marky?

“De quem”, eu queria perguntar de qual classe é esse método.