findViewById returns null

there is no problem with your codes, by right everything should work as per normal.

The most common mistake of encountering null via findViewById() method is when you forgot to call setContentView() or called it for the wrong layout.

I suggest cleaning your project and try again!!!!


I was having the same trouble, but after cleaning my project and running it again it works perfectly.