انجمن وب سایت مشاوره در زمینه پروژه های برنامه نویسی و طراحی وب سایتهای تجاری

نسخه‌ی کامل: نوشتن رخداد کلیک برای ImageButton در اندروید
شما در حال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب بندی مناسب.
برای ایجاد رخداد کلیک برای ImageButton در Android Studio از متد زیر می توان استفاده کرد:

کد:
ImageButton imageButton = (ImageButton)findViewById(R.id.IBtnNext);
        imageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              
// محل کد ها برای رخداد کلیک

            }
        });

و کد XML کلید ایجاد شده به شرح ذیل می باشد:

کد:
<ImageButton
        android:id="@+id/IBtnNext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:src="@android:drawable/ic_media_rew"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent" />
لینک مرجع