SlideShare a Scribd company logo
1 of 18
Download to read offline
Hi! 
AndroidAnnotations 
㥮⶷疍 
yes 
! 
2014.10.28 Android Taipei @ PicCollage
Story 1
public class MainActivity extends Activity { 
! 
onCreate() { 
setContentView(R.id.activity_main); 
} 
! 
}
public class MainFragment extends Fragment { 
onCreateView() { 
return inflater.inflate(R.layout.fragment_main, container, false); 
} 
! 
}
public class MainFragment extends Fragment { 
onCreateView() { 
View view = inflater.inflate(R.layout.fragment_main, container, false); 
! 
TextView textView1 = view.findViewById(R.id.textview1); 
TextView textView2 = view.findViewById(R.id.textview1); 
TextView textView3= view.findViewById(R.id.textview1); 
TextView textView4 = view.findViewById(R.id.textview1); 
! 
textView1.setOnClickListener(new View.OnClickListener() { 
@Override 
public void onClick(View v) { 
} 
}); 
return view; 
} 
! 
}
public abstract class AbstractFragment extends Fragment { 
protected abstract int setRootViewId(); 
int[] setOnClickListenerViews() {} 
} 
public class MainFragment extends AbstractFragment implement View.OnClickListener 
@Override 
protected int setRootViewId() { return R.layout.fragment_main } 
@Override 
int[] setOnClickListenerViews() { return new int[] { R.id.button_ok, R.id.button_no } } 
! 
@Override 
public void onClick(View v) { 
switch (v.getId) { 
case R.id.button_ok: 
… 
} 
}
Story 2
Android Studio 
;
support-annotations
(;゚д゚)
@Efragment(R.layout.fragment_main) 
public class MainFragment extends Fragment { 
! 
@Click(R.id.button_ok) 
void ok() { 
… 
} 
! 
! 
! 
! 
! 
! 
} 
@LongClick(R.id.button_ok)
@Efragment(R.layout.fragment_main) 
public class MainFragment extends Fragment { 
! 
@FragmentArgs 
int position; 
} 
Fragment fragment = MainFragment_.builder().position(7).build();
@Receiver(actions = BluetoothLeService.ACTION_DATA_AVAILABLE) 
void onHeartRateChanged() { 
startHRVMeasure(); 
}
@EActivity 
@OptionsMenu(R.menu.menu_main) 
public class MainActivity extends Activity { 
! 
! 
! 
! 
! 
! 
! 
! 
! 
} 
@OptionsItem(R.id.menuitem_refresh) 
void refresh() { 
… 
}
@SharedPref 
public interface MyPrefs { 
@DefaultString(yes) 
String name(); 
} 
@EActivity 
public class MyActivity extends Activity { 
@Pref 
MyPrefs_ myPrefs; 
String name = myPrefs.name().get(); 
}
Java's Annotation Processing Tool 
@EActivity 
MainActivity 
MainActivity_ 
extends MainActivity 
Compiler
Thanks for your listening 
Reference: 
! 
AndriodAnnotations 
http://androidannotations.org/ 
! 
android-apt 
https://bitbucket.org/hvisser/android-apt

More Related Content

What's hot

STYLISH FLOOR
STYLISH FLOORSTYLISH FLOOR
STYLISH FLOORABU HASAN
 
Button
ButtonButton
ButtonLwp Xd
 
Android - Working with Fragments
Android - Working with FragmentsAndroid - Working with Fragments
Android - Working with FragmentsCan Elmas
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in androidPrawesh Shrestha
 
Building android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...
Building  android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...Building  android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...
Building android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...Hammad Tariq
 
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamViolet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamAnton Caceres
 
Design for succcess with react and storybook.js
Design for succcess with react and storybook.jsDesign for succcess with react and storybook.js
Design for succcess with react and storybook.jsChris Saylor
 
Android Workshop
Android Workshop Android Workshop
Android Workshop Home
 
[Individual presentation] android fragment
[Individual presentation] android fragment[Individual presentation] android fragment
[Individual presentation] android fragmentGabriele Vecchia
 

What's hot (12)

STYLISH FLOOR
STYLISH FLOORSTYLISH FLOOR
STYLISH FLOOR
 
Hola mundo12
Hola mundo12Hola mundo12
Hola mundo12
 
Fragment
Fragment Fragment
Fragment
 
Button
ButtonButton
Button
 
Android - Working with Fragments
Android - Working with FragmentsAndroid - Working with Fragments
Android - Working with Fragments
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
Building android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...
Building  android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...Building  android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...
Building android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...
 
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamViolet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
 
Design for succcess with react and storybook.js
Design for succcess with react and storybook.jsDesign for succcess with react and storybook.js
Design for succcess with react and storybook.js
 
Android gui framework
Android gui frameworkAndroid gui framework
Android gui framework
 
Android Workshop
Android Workshop Android Workshop
Android Workshop
 
[Individual presentation] android fragment
[Individual presentation] android fragment[Individual presentation] android fragment
[Individual presentation] android fragment
 

Similar to Hi AndroidAnnotations

Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureAlexey Buzdin
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureC.T.Co
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
How to code to code less
How to code to code lessHow to code to code less
How to code to code lessAnton Novikau
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android DevelopmentJussi Pohjolainen
 
Rohit android lab projects in suresh gyan vihar
Rohit android lab projects in suresh gyan viharRohit android lab projects in suresh gyan vihar
Rohit android lab projects in suresh gyan viharRohit malav
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo Ali Parmaksiz
 
Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)Danny Preussler
 
Net conf BG xamarin lecture
Net conf BG xamarin lectureNet conf BG xamarin lecture
Net conf BG xamarin lectureTsvyatko Konov
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design PatternsGodfrey Nolan
 
Saindo da zona de conforto… resolvi aprender android
Saindo da zona de conforto… resolvi aprender androidSaindo da zona de conforto… resolvi aprender android
Saindo da zona de conforto… resolvi aprender androidDaniel Baccin
 
React Native Androidはなぜ動くのか
React Native Androidはなぜ動くのかReact Native Androidはなぜ動くのか
React Native Androidはなぜ動くのかYukiya Nakagawa
 

Similar to Hi AndroidAnnotations (20)

Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
20 Codigos
20 Codigos20 Codigos
20 Codigos
 
20 codigos
20 codigos20 codigos
20 codigos
 
Android crashcourse
Android crashcourseAndroid crashcourse
Android crashcourse
 
Fragments anyone
Fragments anyone Fragments anyone
Fragments anyone
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
How to code to code less
How to code to code lessHow to code to code less
How to code to code less
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android Development
 
Rohit android lab projects in suresh gyan vihar
Rohit android lab projects in suresh gyan viharRohit android lab projects in suresh gyan vihar
Rohit android lab projects in suresh gyan vihar
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
 
Android 3
Android 3Android 3
Android 3
 
20 códigos de eclipse
20 códigos de eclipse20 códigos de eclipse
20 códigos de eclipse
 
Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)
 
Androidppt 1
Androidppt 1Androidppt 1
Androidppt 1
 
Net conf BG xamarin lecture
Net conf BG xamarin lectureNet conf BG xamarin lecture
Net conf BG xamarin lecture
 
ButterKnife
ButterKnifeButterKnife
ButterKnife
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design Patterns
 
Saindo da zona de conforto… resolvi aprender android
Saindo da zona de conforto… resolvi aprender androidSaindo da zona de conforto… resolvi aprender android
Saindo da zona de conforto… resolvi aprender android
 
React Native Androidはなぜ動くのか
React Native Androidはなぜ動くのかReact Native Androidはなぜ動くのか
React Native Androidはなぜ動くのか
 

Recently uploaded

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 

Recently uploaded (20)

Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 

Hi AndroidAnnotations

  • 1. Hi! AndroidAnnotations 㥮⶷疍 yes ! 2014.10.28 Android Taipei @ PicCollage
  • 3. public class MainActivity extends Activity { ! onCreate() { setContentView(R.id.activity_main); } ! }
  • 4. public class MainFragment extends Fragment { onCreateView() { return inflater.inflate(R.layout.fragment_main, container, false); } ! }
  • 5. public class MainFragment extends Fragment { onCreateView() { View view = inflater.inflate(R.layout.fragment_main, container, false); ! TextView textView1 = view.findViewById(R.id.textview1); TextView textView2 = view.findViewById(R.id.textview1); TextView textView3= view.findViewById(R.id.textview1); TextView textView4 = view.findViewById(R.id.textview1); ! textView1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); return view; } ! }
  • 6. public abstract class AbstractFragment extends Fragment { protected abstract int setRootViewId(); int[] setOnClickListenerViews() {} } public class MainFragment extends AbstractFragment implement View.OnClickListener @Override protected int setRootViewId() { return R.layout.fragment_main } @Override int[] setOnClickListenerViews() { return new int[] { R.id.button_ok, R.id.button_no } } ! @Override public void onClick(View v) { switch (v.getId) { case R.id.button_ok: … } }
  • 10.
  • 12. @Efragment(R.layout.fragment_main) public class MainFragment extends Fragment { ! @Click(R.id.button_ok) void ok() { … } ! ! ! ! ! ! } @LongClick(R.id.button_ok)
  • 13. @Efragment(R.layout.fragment_main) public class MainFragment extends Fragment { ! @FragmentArgs int position; } Fragment fragment = MainFragment_.builder().position(7).build();
  • 14. @Receiver(actions = BluetoothLeService.ACTION_DATA_AVAILABLE) void onHeartRateChanged() { startHRVMeasure(); }
  • 15. @EActivity @OptionsMenu(R.menu.menu_main) public class MainActivity extends Activity { ! ! ! ! ! ! ! ! ! } @OptionsItem(R.id.menuitem_refresh) void refresh() { … }
  • 16. @SharedPref public interface MyPrefs { @DefaultString(yes) String name(); } @EActivity public class MyActivity extends Activity { @Pref MyPrefs_ myPrefs; String name = myPrefs.name().get(); }
  • 17. Java's Annotation Processing Tool @EActivity MainActivity MainActivity_ extends MainActivity Compiler
  • 18. Thanks for your listening Reference: ! AndriodAnnotations http://androidannotations.org/ ! android-apt https://bitbucket.org/hvisser/android-apt