我在我的代码中添加了多选模式侦听器:
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;
}
现在我的问题是ImageView的onClick影响listview的multimodeListener。由于长按 imagr 的 onClickListener 导致多模式侦听器无法正常工作。