简体   繁体   中英

Java equivalent of Kotlin class with superclass constructor call

class FirstFragment : Fragment(R.layout.fragment_first){
}

I am new to android app development. I was trying to learn how to do a few things and I haven't studying Kotlin yet, how would I turn this small piece of code into the java class?

public class FirstFragment {
    
}

This is the Java version of your code:

public class FirstFragment extends Fragment {

    public FirstFragment() {
        super(R.layout.fragment_first);
    }

}

You inherit from Fragment with the extends keyboard and then you call the alternate constructor (the one with the layout parameter) from your default constructor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM