Reputation: 190
Right now I am in the process of creating a custom date picker on screen in a test app, but I wish to use it in multiple activities in my app, and it is complex enough that I just don't want to copy and past the code. I was wondering whether there is a way to nicely package it so I can reuse it easily.
Thanks for any help and info!
Upvotes: 2
Views: 1094
Reputation: 1257
Create a custom view (aka widget) following this "Guide" implementing all your customizations you currently have to the view in your activity (as I understood) and then you can reuse your widget anywhere in this application or even on other applications (this is if you export this view into separate lib, and is subject for another discussion)
Upvotes: 0
Reputation: 3923
Create whatever widget u intend to in a separate layout resource say "my_widget. xml"
And then use it another activity's xml (say activity_1.xml) by calling your widget in it, using
<include layout=@layout/my_widget />
Upvotes: 1