I have Written all the code well but i dont know what is the erroe and how to slove it. While i run the programm the following error will occure
Asked
Active
Viewed 70 times
-1
-
Its a NPE error. may be you are trying to set a null value to the create.setText() Check if content is not null – Jerry Sep 12 '15 at 06:11
-
Where to check is it content is null or not – John Sep 12 '15 at 06:22
-
the line create.setText(**content**). check whether **content** is null or not. Just put an if statement before your create.setText(**content**) and check if **content** is null, if yes make a toast that it is, else set the value to the textview – Jerry Sep 12 '15 at 06:27
-
Post you layout XML file – Want2bExpert Sep 12 '15 at 06:39
-
what is the code line @ Login.java:161 – A.R. Sep 12 '15 at 06:50
-
@ Login.java:161 content.setSpan(new UnderlineSpan(), 0, udata.length(), 0); @ Login.java:162 create.setText(content); – John Sep 12 '15 at 06:56
-
I have Updated my question – John Sep 12 '15 at 08:00
-
make sure, android:id="@+id/createacc" is not defined for any other view in your xmls. – A.R. Sep 12 '15 at 08:21
-
are you sure that `content.setSpan(new UnderlineSpan(), 0, data.length(), 0);` causes the exception? Beacuse I copied that part of your code to a new project and it's working for me.... :/ – bendaf Sep 12 '15 at 08:39
-
ya content.setSpan causes the exception – John Sep 12 '15 at 09:47
2 Answers
0
I think you did mistake somewhere else in your xml file, please recheck it.
android:id="@id/btnClick"
it should be like this,
android:id="@+id/btnClick"
Please check in your xml file everywhere.
Parth Bhayani
- 2,176
- 3
- 15
- 35
-
-
Well, you need to check all your ids and its values, that's the concern with this. – Parth Bhayani Sep 12 '15 at 06:43
0
It may be possible that you are setting the text before binding the view in the class with the view in xml...
Put these two lines in onCreate() method after the setContentView(); statement...
trouble = (TextView) findViewById(R.id.trouble_login);
create=(TextView)findViewById(R.id.createacc);
Let me know if this works for you.
And if it does, mark it as an answer so that it would be useful to others...
Rohit Jagtap
- 1,660
- 1
- 13
- 12
-
-
-
-
-
You haven't put the whole code of Login.java. I tested it and its running successfully, the error is at line no 161, put the whole code – Rohit Jagtap Sep 12 '15 at 07:16
-
-
@ Login.java:161 content.setSpan(new UnderlineSpan(), 0, udata.length(), 0); @ Login.java:162 create.setText(content); – John Sep 12 '15 at 08:01
-