简体   繁体   中英

How to open a kotlin fragment from java Activity?

我在 java 中有一个活动MainActivity ,在 Kotlin 中有一个片段FirstFragment ,在MainActivity编写代码来打开FirstFragment

getSupportFragmentManager().beginTransaction().replace(R.id.my_container, new FirstFragment()).commit();

You can call kotlin and java from each other, you just import the class and call it. Does not matter if it is kotlin or not.

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