I haven't found anything over the past day that shows how to do this action, everything I've seen is with a basic button of which I am unable to replicate for use with an image button. using setOnClickListener does not seem to work at all though the only cases I found of using them were 5+ years old.
Is there a Storyboard equivalent of linking activities in Android Studio?
Here is an example I found but 7 years old.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val myButton =
findViewById<View>(R.id.live) as ImageButton
myButton.setOnClickListener(object : OnClickListener() {
// When the button is pressed/clicked, it will run the code below
fun onClick() {
// Intent is what you use to start another activity
val intent = Intent(this, LiveActivity::class.java)
startActivity(intent)
}
})
}
}
gives the following error:
Object is not abstract and does not implement abstract member public abstract fun onClick(p0: View!): Unit defined in android.view.View.OnClickListener