In an onCreate()
method I have the following code:
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.mapview);
setupGui();
mHandler = new Handler();
mv = new MapView();
(new Thread(){
public void run() {
while (true) {
try {
Thread.sleep(1000);
mHandler.post(new Runnable() {
@Override
public void run() {
mv.createPlane(true);
}
});
} catch (Exception e) {
}
}
}
}).start();
}
Where mv is the name of the class I am in, which contains a createPlane(boolean)
method for placing some new elements onto the UI. This method:
public void createPlane(boolean left) {
linL = (LinearLayout) findViewById(R.id.ll);
}
And this does not work. (NullPointerException
at findViewById()
)