今天在写Fragment的时候,又碰到了之前常用的代码
@Override
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState)
{
View view=inflater.inflate(R.layout.fragment_butler,container,false);
return view;
}
之前我都是按照上述方式完成代码,这次我突发奇想将第三个false去掉
View view=inflater.inflate(R.layout.fragment_butler,container);
结果发生了以下错误
java.lang.StackOverflowError: stack size 8MB
at android.widget.TextView.jumpDrawablesToCurrentState(TextView.java:5342)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:6321)
at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:63
这时我再把第二个参数也改为null,错误消失。于是我去StackOverflow查询了相关错误,果然有人之前碰到过,下面贴出答主的回答。