[英]Can't find listener for bar icon
I'm working on an app that, thought the method setHomeAsUpIndicator
, replaces the title of the activity.我正在开发一个应用程序,认为方法setHomeAsUpIndicator
替换了活动的标题。 So far everything makes sense because it can be understood by reading the documentation , but I can't figure out why, when I press the icon, a certain Activity is launched.到目前为止一切都有意义,因为可以通过阅读文档来理解它,但是我无法弄清楚为什么,当我按下图标时,某个 Activity 被启动。 This specific part of the code looks like this:代码的这一特定部分如下所示:
private void myMethod() {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(
ContextCompat.getDrawable(this, R.drawable.someIcon)
);
actionBar.setHomeActionContentDescription(
getResources().getString(R.string.correspondingDescription)
);
actionBar.setDisplayShowTitleEnabled(false);
}
When someIcon
is pressed, another Activity is launched, but I don't know where is that indicated.当someIcon
被按下时,另一个 Activity 被启动,但我不知道它在哪里指示。
Thanks for the help!谢谢您的帮助!
It moves to previous activity because there is a parent activity set in a AndroidManifest.xml file, like this :它移动到上一个活动,因为在 AndroidManifest.xml 文件中设置了一个父活动,如下所示:
<activity
android:name=".ExampleActivity"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.