If findViewById() returns NPE, try a few of them:
- Clean the project through Project → Clean ... → check your project → OK
- Make sure you have absolutely no spelling errors in the ID
- Make sure the contentView displays the correct layout where
TableLayout exists - Make sure you
setContentView before findViewById
I assume that the third option that I have listed is most likely your problem.
Re-cleaning the project can also help after each of these steps.
source share