Android buttona tıklanma..
Önce xml sayfasına giderek button oluşturulur.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Aktivity.GostermeActivity">
<com.google.android.material.button.MaterialButton
android:id="@+id/ayarla"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_margin="5dp"
android:fontFamily="@font/abril_fatface"
style="@style/Widget.MaterialComponents.TimePicker.ImageButton"
android:text="ayarla"
android:textAllCaps="true"
android:textStyle="bold" />
</RelativeLayout>
Sonra id ile clasa bağlanır..
public class GostermeActivity extends AppCompatActivity {
Button ayarla;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gosterme);
ayarla = findViewById(R.id.ayarla);
ayarla.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(this, "Butona tıklandı ", Toast.LENGTH_LONG).show();
}
});
}
}