title: kotlin.NotImplementedError: An operation is not implemented: not implemented Error from ImageButton Click
body: <p>Getting this Error </p>
  
  <blockquote>
    <p><strong>kotlin.NotImplementedError: An operation is not implemented: not implemented</strong></p>
  </blockquote>
  
  <p>I am implementing an ImageButton click listener </p>
  
  <p><strong>Requirement</strong> :- I want to perform an action on imagebutton click , but getting the above mentioned error</p>
  
  <p>Correct me and also  if there is any other work around to implement imagebutton click listener, do provide it , Thanks</p>
  
  <p>Here is the <code>fragment</code> java class</p>
  
  <pre><code>class FragmentClass : Fragment(), View.OnClickListener {
      override fun onClick(v: View?) {
          TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
          when (v?.id) {
              R.id.back_icon -&gt; {
                  Toast.makeText(activity, "back button pressed", Toast.LENGTH_SHORT).show()
                  activity.onBackPressed()
              }
  
              else -&gt; {
              }
          }
      }
  
      override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?,
                                savedInstanceState: Bundle?): View? {
          val view: View = inflater!!.inflate(R.layout.fragment_class, container,
                  false)
          val activity = getActivity()
          var input_name = view.findViewById(R.id.input_name) as EditText
          var tv_addbucket = view.findViewById(R.id.tv_addbucket) as TextView
          val back_icon: ImageButton = view.findViewById(R.id.back_icon)
          back_icon.setOnClickListener(this)
  
          tv_addbucket.setOnClickListener(View.OnClickListener {
              Toast.makeText(activity, input_name.text, Toast.LENGTH_SHORT).show()
          })
  
  
          return view;
      }
  
  
  }
  </code></pre>
  
  <p>and then the <code>fragment_class. xml</code> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;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"&gt;
  
      &lt;RelativeLayout
          android:id="@+id/header"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:focusable="true"
          android:focusableInTouchMode="true"
          android:clickable="true"
          android:padding="10dp"&gt;
  
          &lt;ImageButton
              android:id="@+id/back_icon"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:background="#0000"
              android:focusable="true"
              android:focusableInTouchMode="true"
              android:clickable="true"
              android:src="@drawable/back_icon" /&gt;
  
          &lt;TextView
              android:id="@+id/tv_header"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_centerHorizontal="true"
              android:text="Add Bucket" /&gt;
      &lt;/RelativeLayout&gt;
  
      &lt;ScrollView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/header"
          android:fillViewport="true"&gt;
  
          &lt;LinearLayout
              android:layout_width="fill_parent"
              android:layout_height="match_parent"
  
              android:layout_marginTop="?attr/actionBarSize"
              android:orientation="vertical"
              android:paddingLeft="20dp"
              android:paddingRight="20dp"
              android:paddingTop="60dp"&gt;
  
              &lt;android.support.design.widget.TextInputLayout
                  android:id="@+id/input_layout_name"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"&gt;
  
                  &lt;EditText
                      android:id="@+id/input_name"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:hint="Bucket Name"
                      android:singleLine="true" /&gt;
              &lt;/android.support.design.widget.TextInputLayout&gt;
  
  
              &lt;TextView
                  android:id="@+id/tv_addbucket"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="40dp"
                  android:background="@drawable/blue_stroke_background"
                  android:gravity="center"
                  android:padding="15dp"
                  android:text="Add"
                  android:textColor="@color/white" /&gt;
  
  
          &lt;/LinearLayout&gt;
      &lt;/ScrollView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>