Android GridView 第一个Item 点击没反应

  @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder viewHolder;
        final String path = list.get(position);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.grid_child_item, null);
            viewHolder = new ViewHolder();
            viewHolder.mLinearLayout = (FrameLayout) convertView.findViewById(R.id.childLinearLayout);
            viewHolder.mImageView = (MyImageView) convertView.findViewById(R.id.child_image);
            viewHolder.mCheckBox = (CheckBox) convertView.findViewById(R.id.child_checkbox);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
            viewHolder.mImageView.setImageResource(R.drawable.friends_sends_pictures_no);
        }

        viewHolder.mLinearLayout.getLayoutParams().height = mGridView.getWidth() / 3;

        viewHolder.mImageView.setTag(path);
        viewHolder.mImageView.setOnMeasureListener(new MyImageView.OnMeasureListener() {
            @Override
            public void onMeasureSize(int width, int height) {
                mPoint.set(width, height);
            }
        });
        viewHolder.mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                addAnimation(viewHolder.mCheckBox, viewHolder.mImageView);
            }
        });
        viewHolder.mImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (viewHolder.mCheckBox.isChecked() || baseApplication.IsMaxCount() == false) {
                    if (viewHolder.mCheckBox.isChecked()) {
                        viewHolder.mCheckBox.setChecked(false);
                    } else {
                        viewHolder.mCheckBox.setChecked(true);
                    }
                    viewHolder.mCheckBox.setFocusable(false);
                }
            }
        });
        if (baseApplication.fetchListPath().contains(path)) {
            viewHolder.mCheckBox.setChecked(true);
        } else {
            viewHolder.mCheckBox.setChecked(false);
        }
        Bitmap bitmap = null;
        if (!isScrollStatue()) {
            bitmap = NativeImageLoader.getInstance().loadNativeImage(path, mPoint,
                    new NativeImageLoader.NativeImageCallBack() {
                        @Override
                        public void onImageLoader(Bitmap bitmap, String path) {
                            ImageView mImageView = (ImageView) mGridView.findViewWithTag(path);
                            if (bitmap != null && mImageView != null) {
                                mImageView.setImageBitmap(bitmap);
                            }
                        }
                    });
        }
        if (bitmap != null) {
            viewHolder.mImageView.setImageBitmap(bitmap);
        } else {
            viewHolder.mImageView.setImageResource(R.drawable.friends_sends_pictures_no);
        }
        return convertView;
    }
要这样设置高度 viewHolder.mLinearLayout.getLayoutParams().height = mGridView.getWidth() / 3;
否则第一个item点击没反应

转载于:https://www.cnblogs.com/blogzhangwei/p/4155284.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值