1

コードは次のとおりです。位置 0 でクリック可能であってはなりません。view.setClickable(false) を使用しましたが、役に立ちませんでした。

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // Get the textview and imageview
        int c = ctx.getResources().getColor(R.color.expandlist);
        int selectedColor = ctx.getResources().getColor(R.color.colorexpand);
        View view = super.getView(position, convertView, parent);
        TextView textView = (TextView) view.findViewById(R.id.cust_view);

        Typeface tf = Typeface.createFromAsset(ctx.getAssets(),
                "fonts/segoeuil.ttf");
        ImageView imageView = (ImageView) view.findViewById(R.id.productImage);
        textView.setTypeface(tf);

        //Check the position so that proper values are assigned
        if (position == 0) {
            File sdCardRoot = Environment.getExternalStorageDirectory();
            File yourDir = new File(sdCardRoot, "ProductImages" + "/Main" + ID
                    + ".jpg");
            if (yourDir.getPath() != null) {
                Bitmap picture = BitmapFactory.decodeFile(yourDir.getPath());
                int width = picture.getWidth();
                int height = picture.getWidth();
                float aspectRatio = (float) width / (float) height;
                int newWidth = 149;
                int newHeight = (int) (150 / aspectRatio);
                picture = Bitmap.createScaledBitmap(picture, newWidth,
                        newHeight, true);
                imageView.setImageBitmap(picture);
                textView.setPadding(13, 200, 0, 0);


            }
            textView.setClickable(false);
            imageView.setClickable(false);
            view.setClickable(false);

        } else {
            if (position == 1) {
                if (ProductItemListFragment.videos) {
                    textView.setBackgroundColor(selectedColor);
                } else {
                    textView.setBackgroundColor(Color.TRANSPARENT);
                }
            } else if (position == 2) {
                if (ProductItemListFragment.images) {
                    textView.setBackgroundColor(selectedColor);
                } else {
                    textView.setBackgroundColor(Color.TRANSPARENT);
                }
            } else if (position == 3) {
                if (ProductItemListFragment.story) {
                    textView.setBackgroundColor(selectedColor);
                } else {
                    textView.setBackgroundColor(Color.TRANSPARENT);
                }

            } else {
                textView.setBackgroundColor(Color.TRANSPARENT);
            }
            // hide/remove image
            imageView.setVisibility(View.GONE); // or GONE, as you wish
            textView.setPadding(13, 10, 0, 15);

        }

        return view;
    }
4

0 に答える 0