简体   繁体   中英

How to use a single view from the parent activity to each child activity without writing any code in child activity?

I want to have a same view in my each activity and want to perform the same task in each of my activity on that view. Also, I have a parent activity which is parent of every activity in my app.

One way to do that is to use the same code in each class and xml. But i don't want to copy past the same code in each class.

how can I use only the one view in my parent activity class and reflect same in each child activity.

You may use tag to include the same view at different xml layout files. THis may come helpful in cases like you have to show a view/layout consistently in every screen of your application. So to avoid duplication you can try 'include'ing the layout in all layout files. Please find more information here: http://developer.android.com/training/improving-layouts/reusing-layouts.html

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