receiving NULL parameter in details Fragment

Asked

Viewed 20 times

-1

My Pokemonitem class has a Skill List on it (another class), when I get the "abilities" I get a "null" on my screen instead of the "abilities". Someone can help me?

private fun configDetalhes() {
    Toast.makeText(activity, pokemon.nome, Toast.LENGTH_LONG).show()
   detalhesViewModel.getDetalhes(pokemon.id)
    detalhesViewModel.mResponse.observe(viewLifecycleOwner, {
        if(it.isSuccessful){
            tv_detalhes_nome_pokemon.text = pokemon.nome
            tv_detalhes_habilidades_pokemon.text = it.body()?.abilities.toString()
        }
    })
}

Pokemonitem class

@Entity(tableName = "PokemonItem")
data class PokemonItem(
@PrimaryKey(autoGenerate = false)
val id: String,
@SerializedName("name") val nome: String,
val smallImageUrl: List<PokemonImage>,
val types: List<String>,
val abilities: List<PokemonAbility>

) :Serializable

Pokemonability class

  class PokemonAbility(
  val name: String,
  val text: String
  )  

1 answer

0


Try to replace your Pokemonability class with

data class PokemonAbility(
  val name: String,
  val text: String
  ) :Serializable

Browser other questions tagged

You are not signed in. Login or sign up in order to post.