-
Notifications
You must be signed in to change notification settings - Fork 0
/
CarrosAdapter
62 lines (50 loc) · 1.61 KB
/
CarrosAdapter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package br.com.home.adaptercustomizado;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
/**
* Created by allanromanato on 6/2/15.
*/
public class CarrosAdapter extends ArrayAdapter<Carro> {
Context contexto;
int id;
List<Carro> lista;
public CarrosAdapter(Context contexto, int id, List<Carro> lista){
super(contexto,id,lista);
this.contexto = contexto;
this.lista = lista;
this.id = id;
}
public View getView(int position, View convertView, ViewGroup parent){
View view = convertView;
Carro carro;
ImageView foto;
TextView nome;
TextView dono;
Bitmap raw;
byte[] fotoArray;
if(view == null){
LayoutInflater inflater = LayoutInflater.from(contexto);
view = inflater.inflate(id, parent, false);
}
nome = (TextView)view.findViewById(R.id.textView);
dono = (TextView)view.findViewById(R.id.textView3);
foto = (ImageView)view.findViewById(R.id.imageView);
carro = lista.get(position);
nome.setText(carro.getNome());
dono.setText(carro.getDono());
fotoArray = carro.getFoto();
if(fotoArray!=null){
raw = BitmapFactory.decodeByteArray(fotoArray,0,fotoArray.length);
foto.setImageBitmap(raw);
}
return view;
}
}