Access A Button From Another Class In Android
I know there are similar questions asked before in SO, but sorry to say that, none of them are serving my purpose. I have a button in an activity class, and I want to give its func
Solution 1:
Change:
publicclassTileButton {
publicvoidtile(View view){
if(view.isShown()){
view.setVisibility(View.INVISIBLE);
}else{
view.setVisibility(View.VISIBLE);
}
}
}
// Tile Button
tileButton.setOnClickListener(newOnClickListener() {
@OverridepublicvoidonClick(View v) {
TileButton tileView = newTileButton();
tileView.tile(v);// you can pass any view from here
}
});
Solution 2:
If you want to have same operation in both the activities, Create a public method in one of the activity and just call the method onClick of both buttons. But you cannot control the visibility of an activity which is not even on screen.
Post a Comment for "Access A Button From Another Class In Android"