0
when the person clicks on item A in the fragment categoria I would need to take it to an Activity. And when I click on item B take it to another Activity, so I can make the filters.
Here the class of items:
public class Itens {
    private int imagem;
    public Itens(int imagem) {
        this.imagem = imagem;
    }
    public int getImagem() {
        return imagem;
    }
    public void setImagem(int imagem) {
        this.imagem = imagem;
    }
}
This is the Adapter:
public class CategoriaAdapter extends ArrayAdapter<Itens> {
    private Context context;
    private ArrayList<Itens> lista;
    public CategoriaAdapter(Context context, ArrayList<Itens> lista) {
        super(context,0,lista);
        this.context = context;
        this.lista = lista;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Itens itemPosicao = this.lista.get(position);
        convertView = LayoutInflater.from(this.context).inflate(R.layout.lista_categoria,null);
        ImageView imageView = (ImageView) convertView.findViewById(R.id.image_lista_categoria);
        imageView.setImageResource(itemPosicao.getImagem());
        return convertView;
    }
}
And here the fragment:
public class PorCategoria extends Fragment {
    private ArrayAdapter<Itens> adapter;
    public PorCategoria() {
        // Required empty public constructor
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_por_categoria, container, false);
        final ArrayList<Itens> lista = new ArrayList<Itens>();
        Itens a = new Itens(R.drawable.categoria1);
        Itens b = new Itens(R.drawable.categoria2);
        Itens c = new Itens(R.drawable.categoria3);
        Itens d = new Itens(R.drawable.categoria4);
        Itens e = new Itens(R.drawable.categoria5);
        lista.add(a);
        lista.add(b);
        lista.add(c);
        lista.add(d);
        lista.add(e);
        adapter = new CategoriaAdapter(getActivity(),lista);
        ListView listaCategoria = (ListView) view.findViewById(R.id.list_categoria);
        listaCategoria.setAdapter(adapter);
        return view;
    }
}
						
thanks for the reply but I can’t give the getItemAtposition turns red
– Felipe Moreira
@Felipemoreira corrected for you. I read your question again, and I realized what I wanted. See.
– viana
thank you very much friend, to succeed in giving continuity to my project
– Felipe Moreira
@Felipemoreira if the answer helped you, you can validate it to help other people.
– viana