0
如果我在onClick()方法中調用了方法,但是如果我在onClick()方法中調用它兩次,它將不起作用。Android更改按鈕後的可見性onClick
private void changeVisible() {
if(progressBar.getVisibility() == View.VISIBLE && loginButton.getVisibility() == View.GONE) {
progressBar.setVisibility(View.GONE);
loginButton.setVisibility(View.VISIBLE);
//Toast.makeText(this, "Button visible", Toast.LENGTH_LONG).show();
}
else {
progressBar.setVisibility(View.VISIBLE);
loginButton.setVisibility(View.GONE);
//Toast.makeText(this, "Button invisible", Toast.LENGTH_LONG).show();
}
}
使用案例:
@Override
public void onClick(View v) {
if (v.getId() == R.id.loginButton) {
changeVisible();
...
try {
...
if(...) {
...
}
else {
...
changeVisible();
}
}
catch(Exception e) {
...
changeVisible();
}
}
}
請幫助。第一
解決。 http://stackoverflow.com/questions/13090630/android-view-set-to-visible-and-gone-in-the-same-onclick-method-view-never-show – SBrx