我正在开发一个几乎没有图像滚动的应用程序,然后登陆订阅页面。参考这里的教程:http://www.truiton.com/2013/05/android-fragmentpageradapter-example/,我开发了使图像滚动5次的应用程序,然后将用户带到订阅页面。
然而,图像片段的行为非常缓慢 - > imagefragment但是当我从imagefragment更改为listfragment时非常好。
我修改了像这样的imagefragment代码:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.e("ImageFragment", "Image updated");
View layoutView = inflater.inflate(R.layout.fragment_image, container,
false);
RelativeLayout iv = (RelativeLayout)layoutView.findViewById(R.id.imageView1);
switch (fragVal) {
case 0: // Fragment # 0 - This will show registration form
iv.setBackgroundResource(R.drawable.bg_screen1); break;
case 1: // Fragment # 1 - This will show image
iv.setBackgroundResource(R.drawable.bg_screen2); break;
case 2: // Fragment # 2 - This will show image
iv.setBackgroundResource(R.drawable.bg_screen3); break;
case 3: // Fragment # 3 - This will show image
iv.setBackgroundResource(R.drawable.bg_screen4); break;
case 4: // Fragment # 4 - This will show image
iv.setBackgroundResource(R.drawable.bg_screen5); break;
case 5: // Fragment # 5 - This will show image
iv.setBackgroundResource(R.drawable.bg_screen6); break;
}
return layoutView;
}
并且还将android:largeHeap =“true”添加到AndroidManifest。
看起来需要内存优化。