how to fix ArithmeticException error in android

假如想象 提交于 2019-11-29 17:42:07

This line of code is causing the error. This is what I understood after referring to this link

int c=4;
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT); //this is causing the error
tl.setStretchAllColumns(true);

You need to change it to

TableRow.LayoutParams params = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);

It has to do something related to setStretchAllColumns and width settings due to which there is some internal android calculation which leads to the exception. Just checkout the grepcode with the method that throws the exception and you will get a better idea.

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