ANDROİD BUTTON KULLANMI

Android Button

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn= (Button)findViewById(R.id.btn_btn);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Butona basıldığında yapılacak komutlar
            }
        });
    }
}
<Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/btn_btn"
            android:text="Bluetooth"
            android:layout_margin="10dp"
            android:padding="10dp"
            tools:ignore="MissingConstraints" />

Leave a Reply