android binary xml exception when changing pictures

[亡魂溺海] 提交于 2019-12-11 08:24:13

问题


I'm developing an android app, it's about multilingual story. In this app I can switch from a language to another. Of course this application contains several images and texts. In the arabic language some photos need to be flipped, in the following code I'm flipping 4 images:

if (i == 0) {
    rightImages[i].setImageResource(R.drawable.coverar);
}
if (i == 1) {
    rightImages[i].setImageResource(R.drawable.page1ar);
}
if (i == 4)// for the arabic flipped pages
{
    rightImages[i].setImageResource(R.drawable.page6_flipped);
    leftImages[i].setImageResource(R.drawable.page7_flipped);

}
if (i == 8)// for the arabic flipped pages
{
    rightImages[i].setImageResource(R.drawable.page14_flipped);
    leftImages[i].setImageResource(R.drawable.page15_flipped);
}

if (i != 4 && i != 8) {
    linLay[i].removeAllViews();
    linLay[i].addView(rightImages[i]);

    linLay[i].addView(leftImages[i]);
}

It's crashing and it's giving me the following error :

android.view.InflateException : Binary XML file line #26: Error inflating class <unknown>

The strange about it is that it won't crash when I change page6_flipped,page7_flipped,page14_flipped,page15_flipped to page6,page7,page14,page15.

Please note that I'm using the tablet galaxy note 10.1 2014 edition, on the other hand it isn't crashing on other tablets ( Samsung P7500 Galaxy Tab 10.1 , toshiba at7-a, samsung galaxy tab 3 10.1).

Any help please ?


回答1:


The images are big in size that why you are gettinh inflate exception in inflator layout in imageView,try to make your images small and before replacing set null in imageview(it will automatically call GC).and in application tag of your manifest file,add the below line:

android:Largeheap = "true"



回答2:


The error message is misleading one would think right away there is something wrong in the XML layout file. Although there may be times the cause would be that, the most obvious cause for this is when you have large images placed in only one drawable folder.



来源:https://stackoverflow.com/questions/24156047/android-binary-xml-exception-when-changing-pictures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!