Setting Up Boundaries, 56 of 100 Days of Code
I set up some ground rules for how my app will deal with user input.
You can find a video at the bottom of the page and a link to the source code here.
I added some logic to the EditText field in the Search Activity based on two possible outcomes: when the field is empty, or when it contains text. I started by creating a new ArrayAdapter which holds a single String object which reads “NO RESULTS FOUND”.
When the EditText field is empty, the list updates with the ArrayAdapter containing the entire list of addresses. If the EditText field contains text entered by the user, the list updates with the ArrayAdapter which says “NO RESULTS FOUND”.
This means that if the user enters text and hits enter, the app, currently, says there are no results. Clearing the text also displays the full list again.
I realized the error in my prior approach. I was trying to include the target functionality for the Search Activity without setting any boundaries. This time, I did the reverse.
Starting with the logic for an empty EditText and one with erroneous text, I have room to focus on the actual search logic. I’ll keep this in mind when working on features for apps in the future.
These changes are a placeholder for the time being. Soon I will write the actual logic for this. At this time, I have proof the list will update if text is added.
Picking up where I left off last time, I’m going to add the substitute Homes object. This will be used to store a copy of Homes objects and allow the application to invoke methods from the Homes class.
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 Nikki Wyatt from Pixabay