Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Create AlertDialog no Android Use Visual Studio 2017

$
0
0

Hello Andoroid master, I'm having trouble setting up alert box. I created a class called Veiculoe and inside it I created a method called ExibirAtributos(), I'm trying to create an alert inside this method, as shown below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace Entenda_Objetos_OO.Classes
{
    public class Veiculo
    {
        public int vei_ano;
        public string vei_nome;
        public void ExibirAtributos()
        {
            //define o alerta para exibir os dados em uma caixa de Alerta
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            AlertDialog alertaExibir = builder.Create();
            //Define o Titulo
            alertaExibir.SetTitle("Dados da Classe Veículo");
            alertaExibir.SetIcon(Android.Resource.Drawable.IcDialogInfo);
            alertaExibir.SetMessage("Ano do Veículo: " + vei_ano + "\n" + "Nome : " + vei_nome.ToUpper());
            alertaExibir.SetButton("OK", (s, ev) =>
            {
                alertaExibir.SetMessage("Dados da Classe Veículo Exibidos com Sucesso !!!!");
            });
            alertaExibir.Show();
        }
    }
}

You are giving an error on the line below, in this:

AlertDialog.Builder builder = new AlertDialog.Builder (this);

Where I'm going wrong. I'm waiting, if possible for an answer.

The error message is as follows:

Error CS1503 Argument 1: cannot convert from 'Entenda_Objetos_OO.Classes.Veiculo' to 'Android.Content.Context'


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>