问题
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