I am new to Android and was going through the button documentation. I was wondering if the system knows which view I clicked on. Like this button.
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/self_destruct"
android:onClick="selfDestruct" />
For the callback function selfDestruct, the documentation says the view passed into the function is the one that is clicked on. So I defined my “selfDestruct” function as followed
public void selfDestruct(View view)
{
view.setVisibility(1);
}
So when I clicked on the button, it should have been set to invisible. But it didn’t. What did I do wrong? Or I have to explicitly pass the button “view” to the function in case that system doesn’t know which one I clicked on.
view.setVisibility(View.GONE);try using this method.view.setVisibility(View.INVISIBLE), you can use this too, but the space occupied by the view, will not be gone out of screen. it will be just invisible.