Android 自定义ExpandableListView适配器不工作

Android 自定义ExpandableListView适配器不工作,android,Android,不是Expandablelistview中的子值。召唤 Products_With_ProfileSubModel item = (Products_With_ProfileSubModel) (expandableListDetail.get(expandableListTitle.get(listPosition)).get(expandedListPosition)); 公共类CustomExpandableListAdapter扩展BaseExpandableListAdapter实现

不是
Expandablelistview
中的子值。召唤

Products_With_ProfileSubModel item = (Products_With_ProfileSubModel) (expandableListDetail.get(expandableListTitle.get(listPosition)).get(expandedListPosition));
公共类CustomExpandableListAdapter扩展BaseExpandableListAdapter实现可过滤{
私人语境;
私有ArrayList expandableListTitle;
私有HashMap expandableListDetail;
私人内部布局资源;
私有int layoutsubResourceId;
公共CustomExpandableListAdapter(上下文上下文、int-layoutResourceId、ArrayList expandableListTitle、int-layoutsubResourceId、HashMap expandableListDetail){
this.context=上下文;
this.layoutResourceId=layoutResourceId;
this.expandableListTitle=expandableListTitle;
this.layoutsubResourceId=layoutsubResourceId;
this.expandableListDetail=expandableListDetail;
}
@凌驾
公共对象getChild(int listPosition,int expandedListPosition){
返回this.expandableListDetail.get(this.expandableListTitle.get(listPosition)).get(expandedListPosition);
}
@凌驾
公共长getChildId(int-listPosition、int-expandedListPosition){
返回expandedListPosition;
}
@凌驾
公共视图getChildView(int listPosition、最终int expandedListPosition、布尔isLastChild、视图convertView、视图组父视图){
视图行=转换视图;
视窗夹持器2;
if(行==null){
LayoutInflater充气器=((活动)上下文)。getLayoutInflater();
行=充气器。充气(layoutsubResourceId,父项,false);
holder=新的ViewHolder2();
holder.user\u id=(TextView)row.findViewById(R.id.profile\u product\u id1);
holder.name=(TextView)row.findViewById(R.id.profile\u product\u desc1);
holder.image=(ImageView)row.findViewById(R.id.profile\u product\u img);
row.setTag(支架);
}否则{
holder=(ViewHolder2)row.getTag();
}
ProfileSubModel项为的产品(Products)(ProfileSubModel)(expandableListDetail.get(expandableListTitle.get(listPosition)).get(expandedListPosition));
断言项。getExpandableListDetail()!=null;
holder.user_id.setText(item.getId());
holder.name.setText(item.getName());
holder.image.setImageDrawable(空);
毕加索
.load(item.getImage())
.fit().centerCrop()中的
.插入(支架图像);
返回行;
}
类视图持有者2{
TextView用户id、名称;
图像视图图像;
}
类视图持有者{
text查看用户id、名称、店铺名称、位置、最小数量、发货日期、客户重复;
图像视图图像;
CircleImageView pro_img;
线性布局剖面图;
}
@凌驾
公共int getChildrenCount(int listPosition){
返回this.expandableListDetail.get(this.expandableListTitle.get(listPosition)).size();
}
@凌驾
公共对象getGroup(int listPosition){
返回此.expandableListTitle.get(listPosition);
}
@凌驾
public int getGroupCount(){
返回此.expandableListTitle.size();
}
@凌驾
公共长getGroupId(int-listPosition){
返回列表位置;
}
@凌驾
公共视图getGroupView(int listPosition、布尔isExpanded、视图convertView、视图组父级){
视图行=转换视图;
视窗座;
if(行==null){
LayoutInflater充气器=((活动)上下文)。getLayoutInflater();
行=充气机。充气(layoutResourceId,父级,false);
holder=新的ViewHolder();
holder.user\u id=(TextView)row.findViewById(R.id.profile\u product\u user\u id);
holder.name=(TextView)row.findViewById(R.id.profile\u product\u name);
holder.shop\u name=(TextView)row.findViewById(R.id.profile\u product\u shop\u name);
holder.location=(TextView)row.findViewById(R.id.profile\u product\u location);
holder.image=(ImageView)row.findViewById(R.id.profile\u product\u img);
holder.min\u数量=(TextView)行findViewById(R.id.min\u数量);
holder.deivery_date=(TextView)row.findViewById(R.id.deivery_date);
holder.pro_img=(CircleImageView)row.findViewById(R.id.pro_img);
holder.cust\u repeat=(TextView)row.findViewById(R.id.cust\u repeat);
holder.profile\u lay=(LinearLayout)row.findViewById(R.id.profile\u lay);
row.setTag(支架);
}否则{
holder=(ViewHolder)row.getTag();
}
ProfileModel item=expandableListTitle.get(listPosition)的产品;
holder.user_id.setText(item.getUser_id());
holder.name.setText(item.getName());
holder.shop_name.setText(item.getShop_name());
holder.location.setText(item.getLocation());
holder.min_数量setText(“\u20B9”+item.getMin_数量()+最小订单”);
holder.image.setImageDrawable(空);
毕加索
.load(item.getImage())
.fit().centerCrop()中的
.插入(支架图像);
holder.pro_img.setImageDrawable(空);
毕加索
.load(item.getPro_img())
.fit().centerCrop()中的
.into(holder.pro_img);
holder.shop_name.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图){
意向意向=新意向(带有产品配置文件的产品配置文件,此为供应商配置文件,带有产品配置文件,用于主类);
intent.putExtra(“\u id”,item.getUser\u id());
意图。putExtra(“pro_id”,pro_id);
意图。putExtra(“名称”,catname);
意向。额外(sub_pro_id,sub_pro_id);
intent.putExtra(“category\u pro\u url”,category\u pro\u url);
星触觉(意向);
}
});
holder.pro_img.setOnClickListener(新视图.OnClickL
public class CustomExpandableListAdapter extends BaseExpandableListAdapter implements Filterable {

    private Context context;
    private ArrayList<Products_With_ProfileModel> expandableListTitle;

    private HashMap<Products_With_ProfileModel, List<Products_With_ProfileSubModel>> expandableListDetail;
    private int layoutResourceId;
    private int layoutsubResourceId;

    public CustomExpandableListAdapter(Context context, int layoutResourceId, ArrayList<Products_With_ProfileModel> expandableListTitle, int layoutsubResourceId, HashMap<Products_With_ProfileModel, List<Products_With_ProfileSubModel>> expandableListDetail) {
        this.context = context;
        this.layoutResourceId = layoutResourceId;
        this.expandableListTitle = expandableListTitle;
        this.layoutsubResourceId = layoutsubResourceId;
        this.expandableListDetail = expandableListDetail;
    }

    @Override
    public Object getChild(int listPosition, int expandedListPosition) {
        return this.expandableListDetail.get(this.expandableListTitle.get(listPosition)).get(expandedListPosition);
    }

    @Override
    public long getChildId(int listPosition, int expandedListPosition) {
        return expandedListPosition;
    }

    @Override
    public View getChildView(int listPosition, final int expandedListPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        View row = convertView;
        ViewHolder2 holder;

        if (row == null) {
            LayoutInflater inflater = ((Activity) context).getLayoutInflater();
            row = inflater.inflate(layoutsubResourceId, parent, false);
            holder = new ViewHolder2();
            holder.user_id = (TextView) row.findViewById(R.id.profile_product_id1);
            holder.name = (TextView) row.findViewById(R.id.profile_product_desc1);
            holder.image = (ImageView) row.findViewById(R.id.profile_product_img);

            row.setTag(holder);

        } else {
            holder = (ViewHolder2) row.getTag();
        }
        Products_With_ProfileSubModel item = (Products_With_ProfileSubModel) (expandableListDetail.get(expandableListTitle.get(listPosition)).get(expandedListPosition));
        assert item.getExpandableListDetail() != null;
        holder.user_id.setText(item.getId());
        holder.name.setText(item.getName());
        holder.image.setImageDrawable(null);
        Picasso.get()
                .load(item.getImage())
                .fit().centerCrop()
                .into(holder.image);

        return row;
    }
    class ViewHolder2 {
        TextView user_id, name;
        ImageView image;
    }

    class ViewHolder {
        TextView user_id, name, shop_name, location, min_qty, deivery_date, cust_repeat;
        ImageView image;
        CircleImageView pro_img;
        LinearLayout profile_lay;
    }

    @Override
    public int getChildrenCount(int listPosition) {
        return this.expandableListDetail.get(this.expandableListTitle.get(listPosition)).size();
    }

    @Override
    public Object getGroup(int listPosition) {
        return this.expandableListTitle.get(listPosition);
    }

    @Override
    public int getGroupCount() {
        return this.expandableListTitle.size();
    }

    @Override
    public long getGroupId(int listPosition) {
        return listPosition;
    }

    @Override
    public View getGroupView(int listPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        View row = convertView;
        ViewHolder holder;

        if (row == null) {
            LayoutInflater inflater = ((Activity) context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);
            holder = new ViewHolder();
            holder.user_id = (TextView) row.findViewById(R.id.profile_product_user_id);
            holder.name = (TextView) row.findViewById(R.id.profile_product_name);
            holder.shop_name = (TextView) row.findViewById(R.id.profile_product_shop_name);
            holder.location = (TextView) row.findViewById(R.id.profile_product_location);
            holder.image = (ImageView) row.findViewById(R.id.profile_product_img);
            holder.min_qty = (TextView) row.findViewById(R.id.min_qty);
            holder.deivery_date = (TextView) row.findViewById(R.id.deivery_date);
            holder.pro_img = (CircleImageView) row.findViewById(R.id.pro_img);
            holder.cust_repeat = (TextView) row.findViewById(R.id.cust_repeat);
            holder.profile_lay = (LinearLayout) row.findViewById(R.id.profile_lay);

            row.setTag(holder);

        } else {
            holder = (ViewHolder) row.getTag();
        }
        Products_With_ProfileModel item = expandableListTitle.get(listPosition);
        holder.user_id.setText(item.getUser_id());
        holder.name.setText(item.getName());
        holder.shop_name.setText(item.getShop_name());
        holder.location.setText(item.getLocation());
        holder.min_qty.setText(" \u20B9 " + item.getMin_qty() + " min order");
        holder.image.setImageDrawable(null);

        Picasso.get()
                .load(item.getImage())
                .fit().centerCrop()
                .into(holder.image);

        holder.pro_img.setImageDrawable(null);
        Picasso.get()
                .load(item.getPro_img())
                .fit().centerCrop()
                .into(holder.pro_img);


        holder.shop_name.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Products_With_Profile.this, Vendor_Profile_With_Products_For_Main.class);
                intent.putExtra("_id", item.getUser_id());
                intent.putExtra("pro_id", pro_id);
                intent.putExtra("name", catname);
                intent.putExtra("sub_pro_id", sub_pro_id);
                intent.putExtra("category_pro_url", category_pro_url);
                startActivity(intent);
            }
        });

        holder.pro_img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Products_With_Profile.this, Vendor_Profile_With_Products_For_Main.class);
                intent.putExtra("_id", item.getUser_id());
                intent.putExtra("pro_id", pro_id);
                intent.putExtra("name", catname);
                intent.putExtra("sub_pro_id", sub_pro_id);
                intent.putExtra("category_pro_url", category_pro_url);
                startActivity(intent);
            }
        });

        holder.image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Products_With_Profile.this, Vendor_Profile_With_Products_For_Main.class);
                intent.putExtra("_id", item.getUser_id());
                intent.putExtra("pro_id", pro_id);
                intent.putExtra("name", catname);
                intent.putExtra("sub_pro_id", sub_pro_id);
                intent.putExtra("category_pro_url", category_pro_url);
                startActivity(intent);
            }
        });

        return row;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public boolean isChildSelectable(int listPosition, int expandedListPosition) {
        return true;
    }

    @Override
    public Filter getFilter() {
        return null;
    }
}