android unable to instantiate activity componentinfo

 错误代码

private ListView listV=new ListView(this);

 @Override
 public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
     setContentView(R.layout.listfolder);
     toRoot();
     Log.e(Looper.myLooper()+"", Looper.myQueue()+"");
//     setSelection(0);//没看出来有什么作用
 }

ListView实例化必须在setContentView()之后,所以有必要把listV=new ListView(this);放在onCreate()方法中,这样就不会出错了

祝你好运!

原文地址:https://www.cnblogs.com/nizuimeiabc1/p/4254319.html