简体   繁体   English

从mainactivity设置新活动的actionbar

[英]Setting actionbar of new activity from mainactivity

this might be trivial, but I still hope you can help me. 这可能是微不足道的,但我仍然希望您能帮助我。 My MainActivity is a list, where each row consists of an imagebutton on the left side and a text on the right side. 我的MainActivity是一个列表,其中的每一行都由左侧的图像按钮和右侧的文本组成。 Each row has another image and text. 每行都有另一个图像和文本。 When clicking on the button, a new activity opens and I want the actionbar to have the respective image of the button clicked and the text of the respective row of my MainActivity. 单击按钮时,将打开一个新活动,我希望操作栏单击按钮的相应图像以及MainActivity的相应行的文本。 How can I dynamically change the ressources based on the different buttons? 如何根据不同的按钮动态更改资源?

Thank you for your help 谢谢您的帮助

使用Intent将数据传递到第二个Activity,并使用getIntent()方法获取在第二个Activity中传递的信息,可以使用setTitle()方法更改ActionBar标题,也可以使用setIcon()方法更改图标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM