This is my button in activity_main.xml
<Button
android:text="@string/fs"
android:layout_width="154dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/textView"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp" android:layout_marginBottom="32dp"
app:layout_constraintBottom_toTopOf="@+id/imageView"
app:layout_constraintHorizontal_bias="0.451"
app:layout_constraintVertical_bias="0.069" android:id="@+id/button2"
style="@style/Widget.AppCompat.Button"
android:background="@android:color/holo_green_dark"
android:onClick="flowerpage"/>
This is the button being created I believe in the Mainactivity.kt
fun flowerpage(view: activity2) {
}
I am new to Kotlin, however, I used to HTML where you could connect two web pages together via HTML link, however, this doesn't seem to be as simple.
button2.setOnClickListener {flower_button()}
this shows compiler error. am I missing an import..??
Button. That's just the target function for youronClickattribute, though it currently has the wrong parameter type, and will crash if you try to use it. AnActivity'sViews are created from its layout in thesetContentView()call. It's not really clear what your actual question is, however.