Combining 2 views

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Combining 2 views

Postby michael22 » Wed Jan 30, 2008 5:44 pm

Hi there,

i'm currently trying to make a "framelike" layout. I need a frame containing some components which are always visible und stay the same while using the applications activities.

I have 2 Layouts defined in xml which do what i want. i can also combine to layouts, with adding a second view, but i cant add a sevcond activity (which is against the android design concept...)

can anybody tell me a solution to load a second layout in an opend one because the second layout needs to have sort of singleton behaviour and should be exactly the same on all other activities.
Posts: 8
Joined: Wed Jan 30, 2008 5:37 pm


Postby plusminus » Wed Jan 30, 2008 6:33 pm

Hello michael22,

the SDK provides the following function.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ViewInflate.from(this).inflate(resourceID, rootViewGroup, attachToRoot, additionalInflateParamsMap);
Parsed in 0.031 seconds, using GeSHi

Its description sounds as it will help you further. It goes as follows:
View android.view.ViewInflate.inflate(int resource, ViewGroup root, boolean attachToRoot, Map inflateParams)

public View inflate(int resource, ViewGroup root, boolean attachToRoot, Map inflateParams)
Inflate a new view hierarchy from the specified xml resource. Throws ViewInflate.InflateException if there is an error.

resource ID for an XML layout resource to load (e.g., R.layout.main_page)
root Optional view to be the parent of the generated hierarchy (if attachToRoot is true), or else simply an object that provides a set of LayoutParams values for root of the returned hierarchy (if attachToRoot is false.)
attachToRoot Whether the inflated hierarchy should be attached to the root parameter? If false, root is only used to create the correct subclass of LayoutParams for the root view in the XML.
inflateParams Optional map of additional attribute name/value pairs to apply to the root element. Can be null. Currently, this parameter is only intended to be used internally by Android.

The root View of the inflated hierarchy. If root was supplied and attachToRoot is true, this is root; otherwise it is the root of the inflated XML file.

Let us know if it helped you. :)

Image | Android Development Community / Tutorials
User avatar
Site Admin
Site Admin
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby Tinky » Tue Nov 11, 2008 9:50 am


I am customizig an AdapterView and trying to inflate an xml, but android.view.ViewInflate class is no more part of new version of sdk... is there any other method of inflating an xml...

older code is
ViewInflate inflate = ViewInflate.from( context );
View v = inflate.inflate( rowResID, parent, false, null);
is there any other class to inflate an xml ??

Thanks in advance
Junior Developer
Junior Developer
Posts: 19
Joined: Tue Sep 09, 2008 9:18 am
Location: India

Postby MrSnowflake » Tue Nov 11, 2008 11:16 am

Don't pose the same question 2 times.
User avatar
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby rmanromga » Fri Nov 14, 2008 6:00 am

Yeah don't post the question twice :-)

Any way take a look at the API documentation of the LayoutInflater.....

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  3. View view = inflater.inflate(R.layout.your_layout, null, true);
Parsed in 0.031 seconds, using GeSHi

Posts: 43
Joined: Thu Dec 20, 2007 6:21 am
Location: Baltimore, MD USA


Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests