If findViewById returns null,
you are probably calling
If that's the case, try calling
try {
runOnUiThread(new Runnable() {
@Override
public void run() {
((Button) findViewById(R.id.my_button)).setVisibility(View.GONE);
}
});
} catch (Exception e) {
Toast.makeText(Home.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
you are probably calling
findViewById
before calling setContentView.
If that's the case, try calling
findViewById
AFTER calling setContentView like:
setContentView(R.layout.home);try {
runOnUiThread(new Runnable() {
@Override
public void run() {
((Button) findViewById(R.id.my_button)).setVisibility(View.GONE);
}
});
} catch (Exception e) {
Toast.makeText(Home.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
No comments:
Post a Comment