I get an error like this in logcat when i try to run my script. I compared it and it is the onClickListener. Any suggestions to fix this problem? Still a beginner.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem exists here:
You are getting an exception because
splashscreenis null, and callingsetOnClickListener()on a null pointer is not allowed. The reason that pointer is null is because you need to obtain a reference to the view from your XML using a proper ID. Yoursplash.xmlfile located in res/layout is being loaded as the content view for the Activity, but you should have a properR.idvalue associated with that particular view.In
splash.xml, the View you declare for this purpose should have anandroid:id="@+id/something"attribute in it’s XML declaration (I picked “something” out of the air, this identifier can be whatever you want). You would then call:Then you will get a valid reference to the view and your set method will not fail.
HTH