获取一个活动的参考从另一个机器人 [英] Get reference of one Activity from another in android

查看:89
本文介绍了获取一个活动的参考从另一个机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能获得引用另一项活动,因为我下了动作条的主要活动说 ActivityA ,这个动作条是可见的所有其他活动还有,现在我想访问该的LinearLayout 并使其从隐藏的 ActivityB

我想要做的财产以后这样的。

 的LinearLayout栏=(的LinearLayout)ActivityA.findViewById(R.id.actionbarhome);
bar.setVisibility(LinearLayout.GONE);
 

我应该在那里的地方 ActivityA 的?任何帮助将是AP preciated。

解决方案
  

我怎样才能引用另一个活动

您不知道。

  

现在我要访问此的LinearLayout,并使其从ActivityB隐藏。

没有,你不知道。你想息事宁人。 ActivityA是不可见的,如果ActivityB是在前台。请留下ActivityA孤单。在 onResume() ActivityA,那么只有到那时你担心隐藏操作栏。

How can i get reference to another activity, because i have placed an ActionBar in main activity say ActivityA, this ActionBar is visible on all other activities as well, now i want to access this LinearLayout and make it hidden from ActivityB.

I want to do somthing like this.

LinearLayout bar = (LinearLayout) ActivityA.findViewById(R.id.actionbarhome);
bar.setVisibility(LinearLayout.GONE);

What should be there in place of ActivityA? Any help would be appreciated.

解决方案

How can i get reference to another activity

You don't.

now i want to access this LinearLayout and make it hidden from ActivityB.

No, you don't. You want to leave it alone. ActivityA is not visible if ActivityB is in the foreground. Please leave ActivityA alone. In onResume() of ActivityA, then and only then do you worry about hiding the action bar.

这篇关于获取一个活动的参考从另一个机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆