![](/img/trans.png)
[英]How to open new Activity from a fragment java file by clicking the button on the fragment xml file?
[英]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();
您可以相互调用 kotlin 和 java,您只需导入类并调用它。 是否是 kotlin 都没有关系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.