Android Project - Why I Switched to OnClickListeners

Опубликовано: 01 Апрель 2026
на канале: Coding Fanatic
39
2

Intro
In this update, I'll walk you through how I refactored my code using onClickListeners for starting Activities

Description
I removed the android:onClick xml attributes from the TextViews in order to keep all code related to user interactions in the MainActivity.java file. Assigning ids to the TextViews used for options allowed me to reference them using objects in MainActivity.java. Creating these objects lets the class configure how the TextViews behave by overriding methods from the View class.

View.OnClickListener documentation: https://developer.android.com/referen...)
Switching to OnClickListeners Article: https://www.codingfanatic.com/2019/09...
Travel App source code: https://github.com/codingfanatic/Travel
Click here to subscribe!    / @codingfanatic8526  
Website: https://www.codingfanatic.com/
Twitter:   / rclarkecf  
Github: https://github.com/codingfanatic
LinkedIn:   / richard-clarke-8699a399  

#codingfanatic #Android #100DaysofCode