I have an activitiy with an layout and a ProgressBar:
public class Saldo_Menu extends Activity implements OnClickListener, OnLongClickListener {
static InternetHelper IH;
ProgressBar pleasewait;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pleasewait=(ProgressBar)findViewById(R.id.pleasewait);
IH=new InternetHelper(this);
pleasewait.setVisibility(View.INVISIBLE);
}
I want to activate the progressbar from this helper class InternetHelper, can somebody give me a small example. This gives a nullpointer, since I know I can’t access the UI from there:
public InternetHelper (Context context) {
myContext = context;
}
public void ShowProgressBar(boolean show){
if (show){pleasewait.setVisibility(View.VISIBLE);}else{pleasewait.setVisibility(View.INVISIBLE);}
}
Save a reference to progress bar in your helper class and then use that to access it.
Then you should be able to use your
ShowProgressBar(boolean)function without any problem.