1

I've seen plenty of links that tell me how to create a custom view, but how how do you import an already existing one. I downloaded one and it looks like a whole project. How is it implemented into another project?

user1971
  • 698
  • 2
  • 6
  • 18

1 Answers1

1
  1. Import it as a module via File -> Import Module
  2. Add as a dependency to your project. File -> Project Structure -> Your Module -> Dependencies Tab -> Add -> Module Dependency.
  3. Include in your settings.gradle via include ':module name'
  4. Clean & Build
MrEngineer13
  • 38,642
  • 13
  • 74
  • 93
  • What should be done when it asks for an Eclipse work space or the actual path map? This computer has never had Eclipse on it and does not have an Eclipse work space. – user1971 Jul 08 '14 at 17:23
  • Import only the /lib portion – MrEngineer13 Jul 08 '14 at 17:27
  • I got through the steps and no gradle errors, but it isn't appearing in the CustomViews widget. the lib folder appeared with books on the folder icon, so I am guessing that it is a library. Modules have a blue dot and folder? For the module dependecy the only option that came up was 'app' which is the main app. In the settings.gradle I put include ':lib' (the newly imported module file). Does that sound about right? – user1971 Jul 09 '14 at 05:23
  • It kind of is now, it might not appear in the Custom Views window, but I can copy and past the XML into my own layout. Now it just doesn't want to find the xml file that contains its attributes and is instead looking in my package instead of the one I imported. 'Error:(278) No resource identifier found for attribute 'cacheColorHint' in package 'counter.prebuild'' – user1971 Jul 09 '14 at 14:48
  • Ok, try adding it as a dependency again – MrEngineer13 Jul 09 '14 at 14:55
  • I made app dependent on lib the first time. Switched that and everything was fixed. – user1971 Jul 09 '14 at 15:40