A
A
Albert Kazan2019-05-13 01:20:24
Android
Albert Kazan, 2019-05-13 01:20:24

How to make functions from work?

There is a sidebar called <include>from another xml (sb.xml)
There are buttons (there will be one for now). I wrote a function in the .kt of the sb.xml attached to this, and added it to the button via onclick. I start the application, MainActivity shows sb.xml, but when the button is pressed, everything crashes. It worked when I cut and pasted the function from sb.kt into mainactivity.kt, but that's not it. Otherwise, you will have to write these functions in every activity where there is a sidebar.
setOnClickListener is ignored. in general, everything from sb.kt does not work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2019-05-13
@zagayevskiy

The link between sb.xml and sb.kt remains undisclosed. By itself, such a connection will never appear. Yes, you need to handle these buttons in every place.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question