How to create a template on Android?

Asked

Viewed 56 times

0

Regarding that answer of this question, I asked the author the question

If he chose to store in an Object Array, this question had an image what could be done.

his answer

you can create a template called Pergunta, for example, and have a object Bitmap (or any other typing of your image) within the model. Then just create a List<Pergunta>

The question is what would this model be and how to create it ?

1 answer

3


This template is a normal class, it groups the information you want, in this case Bitmap for example.

It’s basically the idea of object orientation.

public class Pergunta {

    private String nome;
    private Bitmap imagem;

    public Pergunta() {
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public Bitmap getImagem() {
        return imagem;
    }

    public void setImagem(Bitmap imagem) {
        this.imagem = imagem;
    }
}
  • you could comment the code to better understand, otherwise this function needs to be completed

  • Rodolfo, I recommend you study object orientation... Italo’s code is simple. It creates a class called Question and in it it creates methods and functions to set or pick class parameters.

  • @Guihgo got it now

Browser other questions tagged

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