嗨,伙计们,我在两个页面之间导航时遇到内存不足错误,该页面有 2 个图库控件(图片库),每个页面都有一些额外的详细信息来填写个人资料信息。在第一页中,我们可以查看配置文件详细信息,然后我们移至另一个页面以编辑详细信息,然后我们可以从那里单击取消按钮返回到第一页。因此,当连续单击编辑和取消按钮时,配置文件编辑页面会打开和关闭。在重复相同的过程一段时间后,应用程序开始通过内存不足运行,并且在某一阶段应用程序由于内部内存不足而无法加载页面。我正在检查解决此问题的可能解决方案。任何建议或意见将不胜感激。希望得到更好的回应。提前致谢。
以下是我的代码:
edit_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//startActivity(new Intent(ProfileView.this, ProfileEdit.class));
startActivity(new Intent(ProfileView.this, ProfileEditLatest.class));
}
});
下面是画廊适配器的 getView 方法:
public View getView(int position, View convertView, ViewGroup parent) {
/*if (position>data.length || position<0) {
return null;
}*/
View vi=convertView;
ImageView image;
if(convertView==null){
vi = inflater.inflate(R.layout.gridview_single, null);
//TextView text=(TextView)vi.findViewById(R.id.text);;
image=(ImageView)vi.findViewById(R.id.image);
final float scale = activity.getResources().getDisplayMetrics().density;
//int pixels = (int) (100 * scale + 0.5f);
int pixels = (int) (100 * scale + 0.5f);
//i.setLayoutParams(new Gallery.LayoutParams(100, 100));
//image.setLayoutParams(new Gallery.LayoutParams(pixels, pixels));
image.setLayoutParams(new RelativeLayout.LayoutParams(pixels,pixels));
//image.setLayoutParams(new LayoutParams(100,100));
//text.setText("item "+position);
}
else{
image=(ImageView)convertView;
}
try{
vi.setTag(data[position]);
imageLoader.DisplayImage(data[position], activity, image);
}
catch (ArrayIndexOutOfBoundsException e) {
// TODO: handle exception
}
return vi;
}
在上面的一个中,我使用了实现的延迟加载,可在URL
在我的个人资料编辑页面中,我有一个声明为静态的位图对象,在将一些新图像上传到画廊时使用它。
希望以上细节对找到问题的解决方案有所帮助。