I am creating an adapter image and I am having this 2 errors:

this is the code
public class GridViewAdapter {
private Context mcontext;
private int layoutResourceId;
public GridViewAdapter(Context context, int layoutResourceId, ArrayList<Listitem> listitem) {
super(context, layoutResourceId, listitem);
this.layoutResourceId = layoutResourceId;
this.mcontext =context;
}
this is second error
cannot resolve method getitem()
` Listitem item = getItem(position);`
if (row == null) {
LayoutInflater inflater = LayoutInflater.from(mcontext);
row = inflater.inflate(layoutResourceId, parent, false);
holder = new ViewHolder();
holder.imageTitle = (TextView) row.findViewById(R.id.text);
holder.imageView = (ImageView) row.findViewById(R.id.imageView);
row.setTag(holder);
} else {
holder = (ViewHolder) row.getTag();
}
Listitem item = getItem(position);
super try to invoke the super class. You are extending nothing, so implicitly, you are inheriting from Object which, in turn, has no such constructor (a constructor that takes three parameters)
Change
public class GridViewAdapter {
with
public class GridViewAdapter extends ArrayAdapter<ListItem> {
As we know super in java is calling the extended class constructor and in your case it has no extended class. Always remember that if no class is extended super calls the no arg constructor of Object class and object class has no constructor with three parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With