Home > Java > javaTutorial > body text

How to Disable Button in Android Studio

Patricia Arquette
Release: 2024-09-21 22:15:02
Original
308 people have browsed it

How to Disable Button in Android Studio

*First Way: *

button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                view.setEnabled(false);
            }
        });
Copy after login

Second way: Without setOnClickListner

 public void disable(View v){
        v.setEnabled(false);
    }
Copy after login

*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" />
Copy after login

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!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!