Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

object() in object cannot be applied while creating adapter image

Tags:

android

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);
like image 684
Moudiz Avatar asked Feb 21 '26 18:02

Moudiz


2 Answers

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> {
like image 114
Blackbelt Avatar answered Feb 23 '26 08:02

Blackbelt


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.

like image 36
mohor chatt Avatar answered Feb 23 '26 07:02

mohor chatt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!