Construya una clase POJO.java y cree "métodos constructores, captadores y definidores"
class POJO{
public POJO(Drawable proImagePath) {
setProductImagePath(proImagePath);
}
public Drawable getProductImagePath() {
return productImagePath;
}
public void setProductImagePath(Drawable productImagePath) {
this.productImagePath = productImagePath;
}
}
Luego configure los adaptadores a través de recursos de imagen dibujables en CustomAdapter.java
class CustomAdapter extends ArrayAdapter<POJO>{
private ArrayList<POJO> cartList = new ArrayList<POJO>();
public MyCartAdapter(Context context, int resource) {
super(context, resource);
}
public MyCartAdapter(Context context, ArrayList<POJO> cartList) {
super(context, 0, cartList);
this.context = context;
this.cartList = cartList;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
/*
*Here you can setup your layout and references.
**/
ImageView productImage = (ImageView) rootView.findViewById(R.id.cart_pro_image);
productImage.setImageDrawable(POJO.getProductImagePath());
}
}
Luego pase las referencias a través de ActivityClass.java
public class MyCartActivity extends AppCompatActivity{
POJO pojo;
CustomAdapter customAdapter;
ArrayList<POJO> cartList = new ArrayList<POJO>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
customAdapter = new CustomAdapter(this, cartList);
pojo = new POJO(getResources().getDrawable(R.drawable.help_green));
}
}