*First Way: *
button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { view.setEnabled(false); } });
Second way: Without setOnClickListner
public void disable(View v){ v.setEnabled(false); }
*XMl code file: *
<Button android:id="@+id/button" android:onClick="disable" android:layout_margin="8dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button" />
The above is the detailed content of How to Disable Button in Android Studio. For more information, please follow other related articles on the PHP Chinese website!