XML -Android 팽창에 대한 invocationTargetexception
문제
많은 클라이언트에 배포 된 이후로 99%의 시간이 작동하는 코드가 있지만 때로는 다음을 얻습니다.
java.lang.reflect.invocationtargetexception android.widget.linearlayout. .view.layoutInflater.createView (layoutInflater.java:499) com.android.internal.policy.impl.phonelayoutInflater.oncreateView (phonelayoutInflater.java:56) Android.view.view.layoutInflater.createViewFromtag (LayoutInflater.java:562). .layoutInflater.rinflate (LayoutInflater.java:617) Android.view.layoutinflater.inflate (LayoutInflater.java:407) Android.view.layoutinflater.inflate (LayoutInflater.java:320) com.myccode.mycode.myclass.myclass.myclass.myclass.myclass.myclass.myclass.myclass. ) ..... .....
그리고 내 코드에는 다음과 같습니다.
LayoutInflater li = (LayoutInflater) this .getSystemService (context.layout_inflater_service);
theview = li.inflate (r.layout.partofthescreen, somecontainer, false);
따라서 문제는 내가 invocialtargetexception을받는 이유입니다.
감사
해결책
당신은 시도 할 수 있습니다 getLayoutInflater()
당신 대신 getSystemService()
전화, 차이를 만들지는 확실하지 않지만 전화하십시오.
an InvocationTargetException
반사에서 나오고 의미합니다 Method
그것은 불에 던져졌다 Exception
. 기본이 될 수있는 다른 스택 추적의 징후가 보이십니까? Exception
? 그렇지 않다면 잡으십시오 InvocationTargetException
그리고보고 있습니다 getCause()
실제로 무슨 일이 일어나고 있는지 확인합니다.
다른 팁
나는 또한 같은 문제가있었습니다.
나는 그 문제를 해결했다 :
로컬 변수를 만드십시오
private Context **context**;
그런 다음 클래스 생성자 (인수 컨텍스트 컨텍스트가 있음) 에서이 작업을 수행합니다.
this.context=**context**;
LayoutInflater li = (LayoutInflater) **context** .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
theview = li.inflate(R.layout.partofthescreen, somecontainer, false);