Sometime I had a strange problem with my xml views and contained subelements in the Android Eclipse SDK.
For example, I have an xml view called main.xml with LinearLayout and TextView as soon as a child, with identifier textView1. Everything works fine (long time). When you make some basic code changes, this may cause it findViewById(R.id.textView1);to return null. Recompilation does not change anything. This is strange.
After a while I found a workaround ... I copied main.xml into main2.xml and changed it setContentView(R.layout.main)to setContentView(R.layout.main2), and everything worked fine, without changing anything except the link to the layout, even the layout itself was only copied. Content has not been modified. After the first working run, I can remove main2.xml and set the layout back to R.layout.main. More NullPointerException.
Does anyone have an idea what is going wrong and how to fix it without making a stupid copy?
Best, Hacksteak
source
share