File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes what is inflater? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "what is inflater?" Watch "what is inflater?" New topic
Author

what is inflater?

fahimeh hashemian
Ranch Hand

Joined: Aug 07, 2012
Posts: 84
Hi

I read Hello Android book and i dont understand MenuInflater and inflater.
I searched and i read android site but android site had written a brief explanation and i dont understand that what is this and what does it do?

@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}

can anybody explain it with straightforward way with example?
Cheers.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41489
    
  53
Inflating means to read the XML file that describes a layout (or GUI element) and to create the actual objects that correspond to it, and thus make the object visible within an Android app.


Ping & DNS - my free Android networking tools app
fahimeh hashemian
Ranch Hand

Joined: Aug 07, 2012
Posts: 84
Thanks for answer
I want to create the optionsMenu and with select one of items in menu and the page on app changes, do the book use inflator for to read xml file that is for new page after selected item and to create the new page?
Do i understand correctly?
Thanks for help.
Cheers.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41489
    
  53
Sorry, I don't understand what you're asking. Can you rephrase it? Also, what book are you referring to?
fahimeh hashemian
Ranch Hand

Joined: Aug 07, 2012
Posts: 84
I want to create a menu of items and when i selected a items of menu,the page changed and new page will open.
I question is that, Is that a new page opens the inflater to creaets?

Please more explanation of inflater and
MenuInflater.

I read Hello Android book.
I think this book not explained well. Do you know a good book? Can you introduce me?

Please help me
Cheers

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41489
    
  53
Inflation will be used if the layout of the new activity is described via an XML file.

I only read one Android book; here's my review: http://www.javaranch.com/bunkhouse/bookSearch.jsp?title=unlocking+android. Note that there's a 2nd edition out now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is inflater?