Android函数zoomImageFromThum(param1,param2)使用大量RAM和CPU

Android函数zoomImageFromThum(param1,param2)使用大量RAM和CPU,android,image,listview,Android,Image,Listview,当触摸拇指并启动功能时,如何避免40%的CPU使用率和70MB的RAM以10MB启动 这是一个场景: 我有一个可以包含文本或图像的列表视图。 用户可以拍照,并将照片保存到sdcard0,然后通过路径加载到相对的ImageView。 我对它的性能有一些问题 保存图像或文本并将其放入列表视图的适配器: PS:我尝试使用ViewHolder来优化listview,但是我在使用毕加索加载图像时遇到了一些问题,所以我删除了它 如您所见,我使用setTagImgPath从ImageView检索路径 如果图像

当触摸拇指并启动功能时,如何避免40%的CPU使用率和70MB的RAM以10MB启动

这是一个场景: 我有一个可以包含文本或图像的列表视图。 用户可以拍照,并将照片保存到sdcard0,然后通过路径加载到相对的ImageView。 我对它的性能有一些问题

保存图像或文本并将其放入列表视图的适配器: PS:我尝试使用ViewHolder来优化listview,但是我在使用毕加索加载图像时遇到了一些问题,所以我删除了它

如您所见,我使用setTagImgPath从ImageView检索路径

如果图像在ImageView中,我就是这样检索触摸图像的:

如果我不使用getTag方法手动设置路径,应用程序加载触摸图像的速度非常快,但使用getTag方法检索图像的路径,应用程序加载触摸图像的缩放速度非常慢。 有什么建议或帮助吗


还有另一种方法可以在ImageView中检索图像的路径?

在适配器的getView方法中,每次调用此get view时,您都会膨胀xml,请使用一些保持器对此进行优化。因为适配器的getView方法将为每一行调用。您将看到性能的显著提高,并且您正在以高效的方式检索路径谢谢@dex。现在,我优化了适配器并看到了差异。但是如果我手动写入路径,缩放就不会慢,所以getTag可能是一种慢方法?如果我使用支架和装载机,我可以使用一些螺纹吗?或者其他什么?为什么要使用getTag设置路径,您可以直接检索图像路径。如何?我看到stackoverflow,但我只找到了使用标记的方法。如何从ImageView检索图像路径?
@Override
public View getView(int position, View convertView, ViewGroup parent){
    LayoutInflater inflater = (LayoutInflater) getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    convertView = inflater.inflate(R.layout.evento_list_view_line, null);

    ImageView img = (ImageView)convertView.findViewById(R.id.compiti_imageView);
    TextView compito = (TextView)convertView.findViewById(R.id.compiti_text);

    Compiti m = getItem(position);

    if(m.getTestoCompito() != null){

        compito.setText(m.getTestoCompito());
        //Invisibile e non presente nel layout
        img.setVisibility(View.GONE);

    }else if(m.getPathFoto() != null){
        //load img
        Picasso.with(getContext())
                .load(m.getPathFoto())
                .resize(200, 200)
                .centerCrop()
                .into(img);
        //Set the tag for retrieve the path of image from listview
        img.setTag(m.getPathFoto());
    }


    return convertView;
}
// ListView Item Click Listener
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            ImageView image_to_zoom = (ImageView) view.findViewById(R.id.compiti_imageView);

            if (image_to_zoom.getDrawable() != null) {

                //Image IN
                String path = image_to_zoom.getTag().toString();
                zoomImageFromThumb(image_to_zoom, path);

            } else {
                //Imane nope
                Toast.makeText(getApplicationContext(), "No photo here!" , Toast.LENGTH_LONG).show();

            }
        }
    });
    // Retrieve and cache the system's default "short" animation time.
    mShortAnimationDuration = getResources().getInteger(
            android.R.integer.config_shortAnimTime);
private void zoomImageFromThumb(final View thumbView, String imagePath) {
    // If there's an animation in progress, cancel it
    // immediately and proceed with this one.
    if (mCurrentAnimator != null) {
        mCurrentAnimator.cancel();
    }

    // Load the high-resolution "zoomed-in" image.
    final ImageView expandedImageView = (ImageView) findViewById(
            R.id.expanded_image);
    //expandedImageView.setImageResource(imageResId);
    Picasso.with(this)
            .load(imagePath)
            .into(expandedImageView);