当onClicklistener添加到listitem的子视图时,Multichoicemode侦听器无法正常工作

时间:2017-02-16 09:23:30

标签: android listview multichoiceitems

我已将multichoice模式侦听器添加到我的代码中:

   listview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listview.setMultiChoiceModeListener(this);

我的listview adpater getview代码是:

 public View getView(int position, View convertView, @NonNull ViewGroup parent)
{
    final CustomObject customObject = arrayList.get(position);
    final ViewHolder holder;

    if (convertView == null)
    {
        holder = new ViewHolder();
        convertView = LayoutInflater.from(context).inflate(R.layout.list_item_pop_up2, parent, false);

        holder.txtCompanyName = (TextView) convertView.findViewById(R.id.txtCompanyName);
        holder.txtProductName = (TextView) convertView.findViewById(R.id.txtProductName);
        holder.imgBanner = (ImageView) convertView.findViewById(R.id.imgBanner);
        convertView.setTag(holder);
    }
    else
    {
        holder = (ViewHolder) convertView.getTag();
    }

        holder.txtCompanyName.setText(customObject.getCompanyName());
        holder.txtProductName.setText(customObject.getProductName());

        Glide.with(context).load(customObject.getImageUrl()).into(holder.imgBanner);

        holder.imgBanner.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                Intent intent = new Intent(context, SecondActivity.class);
                context.startActivity(intent);
            }
        });

    return convertView;
}

现在我的问题是onView的ImageView会影响listview的multimodeListener。因为多模式监听器无法正常工作而长时间按下onClickListener。

enter image description here

0 个答案:

没有答案