I have another class, which needs to update progressbar in my UI while doing process. I tried 2 methods, both sets my ProgressBar variable to null, so I ended up getting NullPointerException all the time:
Method 1)
MyClass tmp = new MyClass();
tmp.setProgressBar(myprg); // myprg is ProgressBar variable and already have value from findViewById function
Then in MyClass:
public void SetProgressBar(ProgressBar prg)
{
localprg = prg; // I put breakpoint here, it's null after assignment
}
Method 2)
MyClass tmp = new MyClass(container.getContext());
tmp.findProgressBar();
in MyClass:
public class void findProgressBar()
{
localprg = (ProgressBar) ((Activity)c).findViewById(R.id.progress_bar);
}
Both failed, both makes localprg = null.