CustomListAdapter.java
Dosyayı İndir
package com.godoro.androidcustoms;
import android.app.*;
import android.view.*;
import android.widget.*;
import java.util.*;
public class CustomListAdapter extends BaseAdapter{
private Activity activity;
private List<CustomListEntity> entityList;
public CustomListAdapter(Activity activity, List<CustomListEntity> entityList) {
this.activity = activity;
this.entityList = entityList;
}
public int getCount() {
return entityList.size();
}
public Object getItem(int position) {
return entityList.get(position);
}
public long getItemId(int position) {
return entityList.get(position).getEntityId();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view=convertView;
if(view==null){
view=activity.getLayoutInflater().inflate(R.layout.custom_list_row, null);
}
TextView nameView=(TextView)view.findViewById(R.id.nameView);
TextView valueView=(TextView)view.findViewById(R.id.valueView);
ImageView activeImage=(ImageView)view.findViewById(R.id.activeImage);
CustomListEntity entity=entityList.get(position);
int imageId=entity.isEntityActive()?R.mipmap.active_true:R.mipmap.active_false;
nameView.setText(entity.getEntityName());
valueView.setText(Double.toString(entity.getEntityValue()));
activeImage.setImageResource(imageId);
return view;
}
}
Dosyayı İndir