Issue
I want to make a class to process ProgressBar. But i cant find a way to transfer the viewId, which make null pointer error.
This the helperclass:
public class HelperProgressBar {
ProgressBar progressBar;
Activity activity;
int ID;
public HelperProgressBar(Activity activity, int ID) {
this.activity = activity;
this.ID = ID;
progressBar.findViewById(ID);
}
public void showProgressBar(){
progressBar.setVisibility(View.VISIBLE);
activity.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
}
public void hideProgressBar(){
activity.getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
}}
And this how i call it:
HelperProgressBar helperProgressBar = new HelperProgressBar(getApplicationContext(), progressBar.getId());
Solution
because progressBar is in your parent layout, not in progressBar.
Just pass the view so that you can handle it.
public HelperProgressBar(Activity activity, ProgressBar progressBar) {
this.activity = activity;
this.progressBar = progressBar;
}
Answered By - GHH
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.