Error running Activity

-1

When I click on a button, I send it to execute an activity where I show a layout, but when I try to execute it, I get the error:

Java.Lang.ClassNotFoundException: md5f22d74140d7efc8f033f3e312f703c5e.NombreActivity

This is the part where I send the Activity call:

private void BtnActivity_Click(object sender, EventArgs e)
{
        var intent = new Intent(this, typeof(NombreActivity));
        StartActivity(intent);

        OnStop();
 }

But I get error right in the var intent. Any suggestions?

    
asked by EriK 12.12.2017 в 00:11
source

2 answers

2

try with

private void BtnActivity_Click(object sender, EventArgs e)
{
        Intent intent = new Intent(this, typeof(NombreActivity));
        StartActivity(intent);
 }

or

private void BtnActivity_Click(object sender, EventArgs e)
{
        Intent intent= new Intent(this.ApplicationContext, typeof(NombreActivity));
        StartActivity(intent);
 }

I do not use that form to execute a click .. you can do it like that

 Button button = FindViewById<Button>(Resource.Id.btn);
        button.Click += delegate
        {
             Intent intent = new Intent(this, typeof(NombreActivity));
            StartActivity(intent);
        }; 
    
answered by 12.12.2017 в 01:13
-2

From MainActivity.cs , call StartActivity , passing the type of Activity to send, NombreActivity in your code:

button.Click += delegate {
       StartActivity(typeof(NombreActivity));
};

Review the documentation:

How to start an Activity in Xamarin

    
answered by 12.12.2017 в 00:39