Just added a new button to my already-working-fine layout, but the findViewById function seems to be angry with something I don\'t get to understand.
Here\'s a bit o
import yourpackagename.R;
instead of android.R;
import R
of your package
Also Clean
your project that will refresh your entire project then you will also find ID
of button also
Make sure to go through these processes.
1: Make sure you imported your project R file.
import packagename.R
2: Clean your project
3: If the above two solutions doesn't work, do invalidate your cache and restart
If its a syntax related problem, then its got to do with compile time stuff.
If its a problem when the code executes, make sure the layout is inflated. If the listview is found, then the button also must definitely be found.
Some times the file R is not regenetated. Try :
No worry that's is just some common eclipse/android bug it happen often (Well some other times it can also be a small syntax error somewhere in your project but i assume that you already checked that x)
Good luck
while, just by clean you project, rebuild it, or import the R file manually, it might a sad thing to find the id of specified view component still cannot find by the activity. and then, if you check the detailed content of the R file, you will find the id has not generate, and then, what you need to check, if there are something wrong with your own /res file, for example, the name of the layout file, drawable file name, or the variant name of the menu file .etc. all of these could just make the R file cannot generate correctly, or even worse, the R file does not generate out at all.
In Android Studio Build
-> Clean Project
resolved the problem for me.