简体   繁体   中英

How to reuse a same Navigation Drawer in different activities?

My drawer is created by android studio automatically and I realized that its structure is not as it was like when I created handly. API23 suggests developers to use assembled layout files. How can I use the same drawer in different activities with API23?

create xml of only drawer component and include it in every activity layout. After that to write java code of drawer create CommonActivity class which extends activity and write here drawer now user CommonActivity rather than extending Activity class in every activity class

like

public class CommonActivity extends Activity
{
oncreate
{
//drawer code
}
}

public class YourActivity extends CommonActivity
{

//No need to write drawer code here again
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM