java.lang.RuntimeException: Unable to start activity ComponentInfo
原因一:java.lang.NullPointerException即空指针,没有赋值或者赋值错误导致了空指针引用;
解决办法:
mDelButton =(Button) findViewById(R.id.delButton); //控件初始化,即赋值
mDelButton.setOnClickListener(listener); //对控件的引用
mClcButton.setOnClickListener(listener);//仅引用控件没有初始化从而报错
原因二:java.lang.NullPointerException即空指针,在界面中使用spinner时,由于你在进入界面后没有使用Spinner,并且Cursor对象在程序生命周期的onStop()时为判断是否不为空就关闭,然后退出这个界面,这时就会导致出错,因为没调用Cursor,本身就是空的;
解决办法:
<1>在查询前先判断Cursor是否为空:
if(cursor3!=null)
{
cursor3.close();
}
cursor3 = cr3.query(uri2, projection, "wpnumber=?",new String[] {pointName}, null);
<2>再从onStop() 方法中判断是否为空并关闭:
protected void onStop() {
super.onStop();
if(cursor3!=null)
{
cursor3.close();
}
}
错误二:Finalizing a Cursor that has not been deactivated or closed.
同上面的原因二,Cursor关闭的地点有问题!
有帮助请好评。。。。。。谢谢!