I m developing a coverflow with android-coverflow http://code.google.com/p/android-coverflow/
Items are loaded form a WebService, so I load the date in a separate thread like this:
//(in MyActivityClass onCreate)
coverFlow1 = (CoverFlow) findViewById(R.id.coverflow); // coverFlow1 is class member
new Thread(new Runnable() {
public void run() {
MyWebServiceClass.getInstance().getCoverFlowData();
MyActivityClass.this.runOnUiThread(
new Runnable()
{
public void run()
{
MyActivityClass.getInstance().loadItems();
}
});
}
}).start();
The problem is that coverFlow1 isnt available inside the loadItems method (it s null , even if I load it again with : coverFlow1 = (CoverFlow) findViewById(R.id.coverflow);
Maybe I ve done a bad usage of runOnUiThread ( I m new to Android development) ?
Just add
coverFlow1as parameter of your method, isn’t?Also you should call it as
MyActivityClass.this.loadItems(CoverFlow flow);getInstance()there is no reason and you really don’t need and it’s incorrect.