Getting this Error
kotlin.NotImplementedError: An operation is not implemented: not implemented
I am implementing an ImageButton click listener
Requirement :- I want to perform an action on imagebutton click , but getting the above mentioned error
Correct me and also if there is any other work around to implement imagebutton click listener, do provide it , Thanks
Here is the fragment
java class
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 -> {
Toast.makeText(activity, "back button pressed", Toast.LENGTH_SHORT).show()
activity.onBackPressed()
}
else -> {
}
}
}
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;
}
}
and then the fragment_class. xml
<?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">
<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">
<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" />
<TextView
android:id="@+id/tv_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Add Bucket" />
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header"
android:fillViewport="true">
<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">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/input_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Bucket Name"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<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" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Closed
Ealrann opened this issue
Jul 19, 2018
· 2 comments
Comments
Hello,
I got a recurring error when I use the colorButton: If I drag and drop (in fact if I move too fast when I click, whatever) it, I will got the following exception:
Exception in thread "main" kotlin.NotImplementedError: An operation is not implemented.
at imgui.imgui.imgui_dragAndDrop$DefaultImpls.setDragDropPayload(drag & Drop.kt:126)
at imgui.ImGui.setDragDropPayload(imgui.kt:45)
at imgui.imgui.imgui_widgetsColorEditorPicker$DefaultImpls.colorButton(widgets colorEditorPicker.kt:646)
at imgui.ImGui.colorButton(imgui.kt:45)
at org.sheepy.vulkan.sand.graphics.SandUIDescriptor.newFrame(SandUIDescriptor.java:110)
at org.sheepy.vulkan.imgui.ImGuiPipeline.newFrame(ImGuiPipeline.java:377)
at org.sheepy.vulkan.sand.pipelinepool.RenderPipelinePool.execute(RenderPipelinePool.java:74)
at org.sheepy.vulkan.sand.SandApplication.drawFrame(SandApplication.java:169)
at org.sheepy.vulkan.VulkanApplication.mainLoop(VulkanApplication.java:125)
at org.sheepy.vulkan.sand.SandApplication.mainLoop(SandApplication.java:128)
at org.sheepy.vulkan.VulkanApplication.run(VulkanApplication.java:63)
at org.sheepy.vulkan.sand.SandApplication.main(SandApplication.java:178)
Not a big problem, I just open an issue to track it.
I use the last Snapshot «v1.62-beta-02».
Yeah, dragAndDrop is kind of tricky, that’s why I put a TODO()
in the code, hoping that I’d fix that before anyone trigger that. But I was wrong
Try 3653ce4, drag and drop is still bugged, but at least it shouldn’t throw anything
Thank you very much, it does the trick 👍
Ealrann
added a commit
to Ealrann/Lily-Vulkan
that referenced
this issue
Jul 21, 2018
Ealrann
added a commit
to Ealrann/Lily-Vulkan
that referenced
this issue
Oct 21, 2018
2 participants
If you are a Kotlin developer, you might have encountered an error message that says “kotlin.NotImplementedError: An operation is not implemented: not implemented Error from ImageButton Click”. This error usually occurs when you have not implemented a function or a method that is called by an ImageButton click event.
To fix this error, you need to implement the function or method that is called by the ImageButton click event. Here is an example of how to implement a click event for an ImageButton:
val imageButton = findViewById<ImageButton>(R.id.imageButton)
imageButton.setOnClickListener {
// implement your function or method here
// ...
}
In this example, we are using findViewById to get the reference to the ImageButton with an ID of “imageButton”. We then set a click listener on the ImageButton that will execute the code inside the lambda expression when the ImageButton is clicked.
If you are still getting the “kotlin.NotImplementedError: An operation is not implemented: not implemented Error from ImageButton Click” error message, it could be that you have not implemented the function or method that is called by the ImageButton click event correctly.
Here is an example of a function that is called by an ImageButton click event:
fun onImageButtonClick(view: View) {
// implement your function or method here
// ...
}
In this example, we have defined a function called “onImageButtonClick” that takes a View object as a parameter. This function is called when the ImageButton is clicked.
To register the “onImageButtonClick” function with the ImageButton, you need to add the following code to your Activity or Fragment:
val imageButton = findViewById<ImageButton>(R.id.imageButton)
imageButton.setOnClickListener(this::onImageButtonClick)
In this example, we are using findViewById to get the reference to the ImageButton with an ID of “imageButton”. We then set a click listener on the ImageButton that will call the “onImageButtonClick” function when the ImageButton is clicked.
I hope this guide has helped you fix the “kotlin.NotImplementedError: An operation is not implemented: not implemented Error from ImageButton Click” error. Remember to always implement the function or method that is called by the ImageButton click event to avoid this error.
NotImplementedError
kotlin-stdlib / kotlin / NotImplementedError
class NotImplementedError : Error
An exception is thrown to indicate that a method body remains to be implemented.
Constructors
<init> |
NotImplementedError( message: String = "An operation is not implemented.") An exception is thrown to indicate that a method body remains to be implemented. |
© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-not-implemented-error/
«NotImplementedException» is thrown when the control goes into a method that has been declared but has not been implemented completely. Please find below the sample code example from MSDN :-
Sub Main() Try FutureFeature() Catch NotImp As NotImplementedException Console.WriteLine(NotImp.Message) End Try End Sub Sub FutureFeature() Throw New NotImplementedException() End Sub
In the above example FutureFeature method method has not been implemented completely and the statement «Throw New NotImplementedException» throws the exception which is being caught in the catch block of your code. Please debug the code line by line (with F11) to know the exact method throwing the exception. Please visit https://msdn.microsoft.com/en-us/library/system.notimplementedexception(v=vs.110).aspx
for more details