在创建适配器图像对象()在对象不能应用于 [英] object() in object cannot be applied while creating adapter image

查看:143
本文介绍了在创建适配器图像对象()在对象不能应用于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个适配器的形象和我有这2个错误:

这是code

 公共类GridViewAdapter {    私人语境mcontext;
    私人诠释layoutResourceId;    公共GridViewAdapter(上下文的背景下,INT layoutResourceId,ArrayList的<&列表项GT;列表项){
        超(背景下,layoutResourceId,列表项);
        this.layoutResourceId = layoutResourceId;
        this.mcontext =背景;    }

这是第二个错误。

无法解析法的GetItem()

 `列表项项=的getItem(位置);`如果(行== NULL){
            LayoutInflater吹气= LayoutInflater.from(mcontext);
            行= inflater.inflate(layoutResourceId,父母,假);
            持有人=新ViewHolder();
            holder.imageTitle =(TextView中)row.findViewById(R.id.text);
            holder.imageView =(ImageView的)row.findViewById(R.id.imageView);
            row.setTag(保持器);
        }其他{
            支架=(ViewHolder)row.getTag();
        }
        列表项项=的getItem(位置);


解决方案

超级尝试调用超类 。您正在扩展一无所有,所以含蓄,您从对象,反过来,有没有这样的构造函数(一个构造函数三个参数)

继承

修改

 公共类GridViewAdapter {

 公共类GridViewAdapter扩展ArrayAdapter<&列表项GT; {

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> {

这篇关于在创建适配器图像对象()在对象不能应用于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆