Skip to content
Coding Fanatic
  • Android Development
  • News and Reviews
  • Road2Pro
  • Tutorials
  • Services
  • About

Objects Are a Real Trip, 55/100 Days of Code

  • December 16, 2019December 16, 2019
  • by Richard Clarke

I attempted to replace the Strings in the ArrayAdapter with Homes objects. It didn’t go so well.

I assumed that having an ArrayAdapter of Homes objects would allow me to invoke methods from the Homes class upon them. This would simplify the process of checking the zipcodes entered by users since I could write a method which does this for me. You can find a video at the bottom of the page and a link to the source code here.

I had this idea after experimenting with the toString() method of the Homes class. The Object.toString() method returns a String representation of an object. I figured that by overriding the method, I could style the appearance of the addresses.

After this, I could replace the Strings in the ArrayAdapter with the Homes objects. Doing this automatically invokes the toString() method to display the information as needed. However, the ArrayAdapter stores these as Objects, not as Homes Objects.

While it does invoke an overridden toString() method, it doesn’t mean these objects have access to the remaining methods of the Homes class.

I’m going to try a new approach. I will continue using the Homes objects in the ArrayAdapter. However, I’ll use the overridden toString() to instantiate a new Homes object. This new object should have access to the Homes class, allowing me to use the methods as needed.

It’s a stretch, and I’m aware that creating a new Object will use more memory. Right now, this seems like my best shot at finishing this application.

For more on this, watch the YouTube video below. For the source code click here

Join the mailing list to see updates like this every week!
Coding Fanatic

Image by Capri23auto from Pixabay

Related

Houston, We Have Input! 54/100 Days of Code
Setting Up Boundaries, 56 of 100 Days of Code
Richard Clarke
Richard is currently a developer using Java and Android Studio to build custom applications for Android. Richard tutored in mathematics at Montgomery College, and worked in Information Technology before entering the Software Development industry as a Quality Engineer.
100daysofcode Android AndroidDev Java

Related articles

Your New Favorite Stopwatch App!…
Two for Two BABY! 7…
…But the App is for…
Play Store Blues – 5…
Top 4 Tips for Android…
No Dice – 3 of…

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • GitHub
  • YouTube
  • X
  • Instagram
  • LinkedIn
My Tweets

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • X
  • GitHub
  • LinkedIn
  • YouTube

Archives

Theme by Colorlib Powered by WordPress