所以我家里有一个片段(初始),家里有一个底部导航栏,在那个我管理我的片段。在我的初始片段(初始)中,我希望有一个按钮,当你点击它时,它会加载一个新的视图,但我不想让那里的底部导航栏(主页)。
这是我的方法:
fun loadCreateView() {
val intent = Intent(this, createLobby::class.java)
startActivity(intent)
}
我在Intent下面有一条红线说:
None of the following functions can be called with the arguments supplied:
<init>(Context!, Class<*>!)defined in android.content.Intent
<init>(String!, Uri!)defined in android.content.Intent
Context!, String!, Uri!
下划线用红色
如果我为this
更改getcontext()
我可以编译但是当我点击按钮时应用程序崩溃
答案 0 :(得分:0)
似乎我必须将方法放在包含片段的视图中,这解决了它