Monday, 8 July 2013

How can I remove a button or make it invisible in Android?

To remove button in java code:
Button btn=(Button)findViewById(R.id.btn);
btn.setVisibility(View.GONE);
To transparent Button in java code:
Button btn=(Button)findViewById(R.id.btn);
btn.setVisibility(View.INVISIBLE);
To remove button in Xml file:
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
To transparent button in Xml file:
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"/>

No comments:

Post a Comment