1

我正在显示联系人列表。除了该设备有 1620 个联系人之外,一切都很好,因此列表滚动非常缓慢,甚至有时会挂起。

请帮帮我。

我尝试使用检查 getView 方法,ConvertView!=null但它总是多次膨胀相同的视图。提前致谢..

我的 getView 方法代码:-

if(ConvertView==null)
        {   view= mInflater.inflate(R.layout.facebookfriend, null);
                TextView name=(TextView)view.findViewById(R.id.textView1);
                ImageView image=(ImageView)view.findViewById(R.id.imageView1);
            name.setText(mlist.get(position).get("name"));

                String Id=mlist.get(position).get("contactId");
                Log.e("Id",""+Id);
                CheckBox chkbox= (CheckBox)view.findViewById(R.id.checkBox1);
                chkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(
                            CompoundButton buttonView, boolean isChecked) {
                        isSelected.set(position, isChecked);
                    }
                });

                                String photoid=mlist.get(position).get("photoId");
            Log.e("photoid",""+photoid);
                if(mlist.get(position).get("photoId")!=null){
                    Log.e("photoid",""+"photoid");
                    image.setImageBitmap(loadContactPhoto(Id, mlist.get(position).get("photoId")));
            }
        }
    }
4

2 回答 2

1

用于ViewHolder pattern高效ListView。这是有关此的详细教程。尝试在您的应用程序中实现此功能,如果有帮助,请告诉我们。

Android 中高效的 ListView:View Holder 模式

于 2012-06-05T11:38:24.307 回答
0

您可以根据要求使列表视图动态加载数据,请参阅此SO 帖子,您还应该使用ViewHolder使其更高效,请参阅

于 2012-06-05T11:44:30.350 回答