Warm tip: This article is reproduced from stackoverflow.com, please click
kotlin

kotlin syntax for extending a class and implementing an interface

发布于 2020-03-29 20:59:40

I want to extend the class fragment and implement an interface with it in kotlin:

The equivalent in Java would be:

class LockFragment extends  Fragment implements IOnBackPressed

But I cannot find the syntax to define that in kotlin.

From what I've searched it looks like syntax is the same for inheritence and interface implementation in kotlin, but this does not work:

class LockFragment : Fragment() : IOnBackPressed

So which would be the correct syntax for that?

Questioner
user2638180
Viewed
21
Nikolai Shevchenko 2020-01-31 18:17
class LockFragment : Fragment(), IOnBackPressed