我正在试图找出为什么我的应用程序的位图(仅在xml布局中使用)永远不会被回收,因此在用户浏览10/12页后,应用程序会因为outofmemoryexception而崩溃。
我尝试使用Mat分析内存使用情况,我可以在保留堆中找到每个位图。
以下是XML布局中图像的使用方式(每个布局大约1个):
<ImageView
android:id="@+id/imageView"
android:layout_width="fill_parent"
android:layout_height="2000dp"
android:scaleType="fitStart"
android:src="@drawable/welcome"/>
以下是相关的活动代码:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
ImageView but = (ImageView)findViewById(R.id.imageView2);
View.OnClickListener listener = new View.OnClickListener()
{
public void onClick(View view)
{
Intent myIntent = new Intent(view.getContext(), EtaActivity.class);
startActivity(myIntent);
overridePendingTransition(0,0);
finish();
}
};
but.setOnClickListener(listener);
}
public void onDestroy()
{
super.onDestroy();
}
有什么想法吗?