Solution 1 :
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.
Problem :
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 {
}