ViewInflate problem

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

ViewInflate problem

Postby navajo » Mon Jan 12, 2009 1:22 am

Hi,
could anyone please explain me what this line of code is really doing in TabActivity example of API:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class TabTest extends TabActivity {
  3.  
  4.     @Override
  5.  
  6.     protected void onCreate(Bundle savedInstanceState) {
  7.  
  8.         super.onCreate(savedInstanceState);
  9.  
  10.         TabHost tabHost= getTabHost();
  11.  
  12.         LayoutInflater.from(this).inflate(R.layout.example_layout, tabHost.getTabContentView(), true);
  13.  
  14.         ...
  15.  
  16.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

All I found about inflating of xml, LayoutInflater documentation,..., didnt help me to understand what is really happening in the last line of the code above.
Can anybody explain to me what LayoutInflater actually does and what it is used for in that specific case?

What I intended to do is to have separate layout.xml files for each TabHost-Content. It would be great if someone could give me a code-example with how-to-look-xml-files for this particular problem.

Thanks in advance,
navajo
In a world without walls and fences... who needs Windows and Gates?
navajo
Junior Developer
Junior Developer
 
Posts: 15
Joined: Fri Dec 21, 2007 5:55 pm
Location: Germany

Top

Postby MrSnowflake » Mon Jan 12, 2009 1:45 am

I have seen and answered multiple questions about inflating views. But I'll say it again one more time.
To inflate a view, you should do:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. View inflatedView = View.inflate(this, R.layout.layout, null);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby navajo » Mon Jan 12, 2009 1:36 pm

Thanks for repeating it one more time, although it didnt help. I've already seen your and other developers answers on this matter elsewhere.
My problem is to understand what InflatedView does and in what cases it should be used.

I also mentioned my problem with TabHostContents, and it would be great, if someone could explain with a short example how this can be managed.

Hope this time I described my doubt more precisely.

Greetz,
navajo
In a world without walls and fences... who needs Windows and Gates?
navajo
Junior Developer
Junior Developer
 
Posts: 15
Joined: Fri Dec 21, 2007 5:55 pm
Location: Germany

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests