0

Good day, I have a requirement which i need to include a layout (actually a custom Action_bar) to an already created layout (that was done in xml) depending on which intent is being sent. i.e if intent A sends, then include the layout. if intent B sends, don't.

i have successfully added the optional layout, by doing this:

layout = (LinearLayout)findViewById(R.id.ad_linearlayout_id); LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.actionbar_layout, null, true); // layout.addView(view); 

but question is, how do i make it the first view in the layout?.. Please any help will be highly appreciated as always. Thanks

2
  • I'm not sure why you are implementing your own actionbar but if its to add a uniform UX across all version of android consider checking out actionbarsherlock.com Commented Apr 4, 2012 at 17:47
  • @slayton, i knew people will be wondering why am doing it. actually am using greendroid for it but the problem is i have tab activities that get populated from the listview, and greendroid has a different way of adding actionbar for both TabActivity and ListActivity. i end up having the actionbar display twice in the TabActivities because of the Listview.. so i had to create a custom own and use a normal Listactivity for only this particular case when the intent is not sent by the TabActivity. Commented Apr 4, 2012 at 18:03

1 Answer 1

2

You can add the view using an index. For example, the first view will be index 0.

See the doc.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot!! funny missed that one.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.