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开发者_JAVA技巧 appreciated.
You can inflate and grab the Layout of the ActivityA and then use findViewById to grab the Required LinearLayout e.g. :
LayoutInflater inflater = getLayoutInflater();
LinearLayout ll_ActivityA = (LinearLayout) inflater.inflate(R.layout.activity_a,null);
LinearLayout bar = (LinearLayout) ll_ActivityA.findViewById(R.id.actionbarhome);
bar.setVisibility(LinearLayout.GONE);
There is a tutorial in the doc about removing the action bar for a particular activity.
精彩评论