InvocationTargetException on inflating an xml - android

℡╲_俬逩灬. 提交于 2019-11-28 10:04:53

You can try getLayoutInflater() instead of your getSystemService() call, though I am not sure that will make a difference.

An InvocationTargetException comes from reflection, and means the Method that was invoked threw an Exception. Do you see any sign of another stack trace that might be the underlying Exception? If not, try catching InvocationTargetException and looking at getCause() to see what is really going on.

PritiJinny

I also had the same problem.

I solved that problem by:

Make the local variable

private Context **context**;

Then in your class constructor( which has argument Context context) do this

this.context=**context**;

LayoutInflater li = (LayoutInflater) **context** .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

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