我有一个带有布局和 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);
}
我想从这个帮助类 InternetHelper 中激活进度条,有人可以给我一个小例子。这给出了一个空指针,因为我知道我无法从那里访问 UI:
public InternetHelper (Context context) {
myContext = context;
}
public void ShowProgressBar(boolean show){
if (show){pleasewait.setVisibility(View.VISIBLE);}else{pleasewait.setVisibility(View.INVISIBLE);}
}