package com example root myapplication import android content Context

 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
package com.example.root.myapplication;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
/**
* Created by root on 19.01.15.
*/
public class TasksAdapter extends ArrayAdapter<Task>{
public TasksAdapter(Context context, ArrayList<Task> tasks) {
super(context, 0, tasks);
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
Task task = getItem(position);
if(convertView == null){
convertView = LayoutInflater.from(getContext()).inflate(R.layout.listed_task,parent,false);
}
TextView nameView = (TextView) convertView.findViewById(R.id.listed_task_name);
View colorView = (View) convertView.findViewById(R.id.listed_task_color);
ImageView imageView = (ImageView) convertView.findViewById(R.id.listed_task_image);
nameView.setText(task.getName());
colorView.setBackgroundColor(task.getColor());
if (task.getImage() != null) {
imageView.setImageBitmap(task.getImage());
}
return convertView;
}
}