I am using this code for validation and only invisibility view is working .
mute.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mute = (ImageButton) findViewById(R.id.mute);
if (mute.getVisibility() != View.INVISIBLE) {
power.setVisibility(View.INVISIBLE);
} else {
power.setVisibility(View.GONE);
}
}
});
Use this it works..... create boolean variable as global within class but outside methods.
boolean flag=true;
and add this clicked method.
@Override
public void onClick(View v) {
if (flag){
power.setVisibility(View.GONE);
flag=false;
}
else {
flag=true;
power.setVisibility(View.VISIBLE);}
}
});
mute always visible , because you performing visibility with power that why the result coming same.
enjoy coding....