{"id":255447,"date":"2016-03-26T00:15:12","date_gmt":"2016-03-25T16:15:12","guid":{"rendered":"http:\/\/blog.zhenglei.net\/?p=255447"},"modified":"2016-03-26T00:26:10","modified_gmt":"2016-03-25T16:26:10","slug":"android-how-to-automatically-generate-java-code-from-layout-file","status":"publish","type":"post","link":"https:\/\/blog.zhenglei.net\/?p=255447","title":{"rendered":"Android: How to automatically generate Java code from layout file?"},"content":{"rendered":"<p><a href=\"http:\/\/stackoverflow.com\/questions\/7462022\/android-how-to-automatically-generate-java-code-from-layout-file\">http:\/\/stackoverflow.com\/questions\/7462022\/android-how-to-automatically-generate-java-code-from-layout-file<\/a><\/p>\n<p>Normally there are three different ways to do this:<\/p>\n<ol>\n<li>at run time (via annotations per reflection)<\/li>\n<li>at compile time (via annotations or aspects)<\/li>\n<li>at development time (via code generators)<\/li>\n<\/ol>\n<p>A good article to start is <a href=\"http:\/\/spring.io\/blog\/2011\/08\/26\/clean-code-in-android-applications\" rel=\"nofollow\">Clean Code in Android Applications<\/a>.<\/p>\n<p>Ad 1) Two solutions, see<\/p>\n<ul>\n<li>RoboGuice, see <a href=\"http:\/\/code.google.com\/p\/roboguice\/\" rel=\"nofollow\">http:\/\/code.google.com\/p\/roboguice\/<\/a><\/li>\n<li>AndJect, see <a href=\"https:\/\/github.com\/ko5tik\/andject\" rel=\"nofollow\">https:\/\/github.com\/ko5tik\/andject<\/a><\/li>\n<\/ul>\n<p>Ad 2) Android Annotations, see <a href=\"http:\/\/androidannotations.org\/\" rel=\"nofollow\">http:\/\/androidannotations.org\/<\/a><\/p>\n<p>Ad 3) Two solutions, see<\/p>\n<ul>\n<li>the lazy-android plugin as mentioned in this thread, see<br \/>\n<a href=\"http:\/\/marketplace.eclipse.org\/content\/lazy-android\" rel=\"nofollow\">http:\/\/marketplace.eclipse.org\/content\/lazy-android<\/a><\/li>\n<li>MotoDev Studio (available as standalone and as eclipse plugin), see <a href=\"http:\/\/developer.motorola.com\/docstools\/motodevstudio\/\" rel=\"nofollow\">http:\/\/developer.motorola.com\/docstools\/motodevstudio\/<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h1 class=\"post-title entry-title\"><span style=\"color: #ff0000\">Be a lazy but a productive android developer \u2013 Part 7 \u2013 Useful tools<\/span><\/h1>\n<p><a href=\"http:\/\/www.technotalkative.com\/lazy-android-part-7-useful-tools\/\">http:\/\/www.technotalkative.com\/lazy-android-part-7-useful-tools\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/stackoverflow.com\/questions\/74620 &hellip; <a href=\"https:\/\/blog.zhenglei.net\/?p=255447\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[58],"class_list":["post-255447","post","type-post","status-publish","format-standard","hentry","category-software-download","tag-android-2"],"_links":{"self":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts\/255447","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=255447"}],"version-history":[{"count":3,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts\/255447\/revisions"}],"predecessor-version":[{"id":255450,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=\/wp\/v2\/posts\/255447\/revisions\/255450"}],"wp:attachment":[{"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=255447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=255447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.zhenglei.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=255447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}