quinta-feira, 9 de abril de 2015

Android: ArrayAdapter

public class EmpresaConveniadaArrayAdapter extends ArrayAdapter{
    private final Context context;
    private final EmpresaConveniada[] values;

    public EmpresaConveniadaArrayAdapter(Context context, EmpresaConveniada[] values) {
        super(context, R.layout.empresaconveniada_layout, values);
        this.context = context;
        this.values = values;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.empresaconveniada_layout, parent, false);
        TextView txtEmpresaConveniada_Nome = (TextView) rowView.findViewById(R.id.txtEmpresaConveniada_Nome);
        TextView txtEmpresaConveniada_EnderecoCompleto = (TextView) rowView.findViewById(R.id.txtEmpresaConveniada_EnderecoCompleto);
        ImageView imgIcone = (ImageView) rowView.findViewById(R.id.imgIcone);

        EmpresaConveniada empresaConveniada = values[position];
        txtEmpresaConveniada_Nome.setText(empresaConveniada.Nome);
        txtEmpresaConveniada_EnderecoCompleto.setText(String.format("%s, %s - %s ", empresaConveniada.Endereco, empresaConveniada.Numero, empresaConveniada.Bairro));
        imgIcone.setImageResource(SegmentoController.getImagem(empresaConveniada.Segmento));
        return rowView;
    }
}
Postar um comentário