Xamarin Java.Lang.IllegalArgumentException: No view found for id

0

Hello friends, I am receiving a Json in my app in Xamarin but when I try to receive 2 int parameters, this error appears. ..

  

Java.Lang.IllegalArgumentException: No view found for id 0x18 (unknown) for fragment FragmentContainer {a5f3e73 # 1 id = 0x18}

It has never happened to me, as I am debugging my method, I realize that when I try to convert the parameters I receive, the answer gives me null . I would like to know if anyone knows what I'm doing wrong D:

try {
  var response = await client.PostAsync("mipaginabienpadre:3",
    content);

  switch (response.StatusCode) {
    case (System.Net.HttpStatusCode.OK):
      res_Label_api.Text = "good";

      var responseString = await response.Content.ReadAsStringAsync();

      member = new Member();
      memberdatabase = new MemberDatabase();
      member.Name = userName;
      member.Pass = pass;
      member.Firma = firma;
      member.Token_Type = tok_ty;
      member.Access_Token = acc_tok;

      var xjson = JsonConvert.DeserializeObject < RootObject > (responseString); //hasat aquí todo parece funcionar , o al menos puedo ver que me devuelve un json

      int xid;
      Int32.TryParse(xjson.DatosEnvio.IdUsuario, out xid);
      member.ID = xid;


      member.AdminType = xjson.DatosEnvio.AdminType.ToString();

      memberdatabase.AddMember(member);


      Application.Current.MainPage = new NavigationPage(new PageNav());


  }
} catch (Exception ex) {

  await DisplayAlert("", "" + ex.ToString(), "ok");
}

this is the model I'm using ...

public class Tabla {
  public List < Table > Table {
    get;
    set;
  }
}

public class RootObject {
  public DatosEnvio DatosEnvio {
    get;
    set;
  }
  public DatosEnvioJson DatosEnvioJson {
    get;
    set;
  }
  public Tablas Tablas {
    get;
    set;
  }
  public string bandera {
    get;
    set;
  }
  public string mensaje {
    get;
    set;
  }
}

public class DatosEnvio {
  public string Usuario {
    get;
    set;
  }
  public string IdUsuario {
    get;
    set;
  }
  public string Nombre {
    get;
    set;
  }
  public int AdminType {
    get;
    set;
  }

}

public class Dato {
  public int IdUsuario {
    get;
    set;
  }
  public string Usuario {
    get;
    set;
  }
  public string Nombre {
    get;
    set;
  }
}

and my answer

{
    "DatosEnvio": {},
    "DatosEnvioJson": {
        "Table": {
            "campos": [
                "IdUsuario",
                "Usuario",
                "Nombre",
                "AdminType"
            ],
            "datos": [
                {
                    "IdUsuario": 1,
                    "Usuario": "root",
                    "Nombre": "Administrador",
                    "AdminType": 3
                }
            ]
        }
    },
    "tablas": null,
    "bandera": "0",
    "mensaje": "1"
}
    
asked by E.Rawrdríguez.Ophanim 28.03.2018 в 23:30
source

1 answer

1

The error that is giving you is not related to Json, it is an error of Android.

Googling a bit I see that there are people who have had this problem for example by calling Form.Init twice or by assigning the MainPage twice.

I'm pretty sure you're giving the error when calling Application.Current.MainPage = new NavigationPage(new PageNav()); and that actually where the error is on that page or in the navigation.

If the main page is already a navigation page, maybe you should do Application.Current.MainPage.PushAsync(new NavigationPage(new ContentPage()));

Check also the xaml of that page and the initialization code.

    
answered by 05.04.2018 в 13:51