Different between two type of adapter syntax in android -


model 1 :

private context mcontext; public view getview(final int position, view convertview, viewgroup parent) {     layoutinflater inflater = (layoutinflater) mcontext             .getsystemservice(context.layout_inflater_service);     convertview = inflater.inflate("layout name",parent, false);  }  

model two:

private context mcontext; public view getview(final int position, view convertview, viewgroup parent) {     layoutinflater inflater = (layoutinflater) mcontext             .getsystemservice(context.layout_inflater_service);     convertview = inflater.inflate("layout name", null);  } 

difference between 2 snippets:

convertview = inflater.inflate("layout name" , null);

and

convertview = inflater.inflate("layout name", parent, false);

inflate 2 prams: inflate(int resource, viewgroup root)

inflate 3 prams: inflate(int resource, viewgroup root, boolean attachtoroot)

resource: int: id xml layout resource load (e.g., r.layout.main_page)

root: viewgroup: optional view parent of generated hierarchy (if attachtoroot true), or else object provides set of layoutparams values root of returned hierarchy (if attachtoroot false.)

attachtoroot: boolean: whether inflated hierarchy should attached root parameter? if false, root used create correct subclass of layoutparams root view in xml.

see android docs.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -