Problem:
While working with Android you can face the errorFatal Exception:java.lang.RuntimeException:unable to start activity ComponentInfo
MainActivity : java.lang.NullPointer Exception
So how to overcome this run time error in android?
Solution:
This type of error is occurs when you trying to access android control Button orEditText before set main activity. so first set you activity and then after it access the control
Example:
Do not use as belowloginBtn = (Button)findViewById(R.id.button1);u_login = (EditText)findViewById(R.id.editText1);
setContentView(R.layout.activity_main);
Use as belowsetContentView(R.layout.activity_main);
loginBtn = (Button)findViewById(R.id.button1);
u_login = (EditText)findViewById(R.id.editText1);
0 comments:
Post a Comment