gpt4 book ai didi

安卓和 Kotlin : Unresolved reference: home

转载 作者:太空狗 更新时间:2023-10-29 14:40:07 24 4
gpt4 key购买 nike

我有向上主页导航按钮的 Activity 。这是我的听众:

override fun onOptionsItemSelected(item: MenuItem) =
when (item.itemId) {
android.R.id.home -> {
onBackPressed()
true
}
else -> false
}

当我构建这个时,我收到错误: Unresolved reference :主页

最佳答案

或者你可以把这一行放在 onCreate()

supportActionBar?.setDisplayHomeAsUpEnabled(true)

然后在您的 list 中添加如下元数据标记。

<activity
android:name=".YourActivity"
android:label="Your Activity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.app_name.YourActivity" />
</activity>

如果您这样做,则无需在 onOptionsItemSelected() 方法中处理主页按钮按下。

关于安卓和 Kotlin : Unresolved reference: home,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49630836/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com