a. Initialize the control
b. Initialize data
First, define variables
Second, add set and get methods
After adding successfully
3. Add construction method
Fourth, add toString method
5. The container lists_food will be added to Java to store data
ctrl+shift shortcut to replace the Drawable type in Food.java with int type
adding data
generate an object from the list
c. Add a listener to the control
In fact, it can be found from the demonstration effect that not only food, but also some attributes of meals. There is also a name and gender for a person, which is equivalent to filling in personal data. So here we also need an entity class, which is the person class.
Enables monitoring of gender, hobbies, and budget
First, add the person class
Add get and set methods
2. Add the Person object
3. Add a Listener for Gender
Initialize the control object
add listener
Fourth, define three filter items
5. Add a listener for CheckBox (filtering)
set listener
6. Add a Listener to the Budget
1. Initialize a variable to store the budget data, the default is 30.
2. Set the default value (here it is set to 30)
3. Set the listener for the budget (create an inner class to implement the OnSeekBarChangeListener interface)
4. Initialize the object of the listener class
5. Generate an object of the listener class and add a listener to seekBar.
6. Debug it
It was found that a null pointer exception occurred. Reason: The checkBox object was not obtained for sour.
Change the spicy code
The most important, core monitoring: find, that is, the listener of the find button
7. Add listeners for find and show
1. Create a listener class
2. Create a List<Food> to save the checked dishes
3. Initialize lists_get to generate objects.
4. Implement the search function in the listener class (find out the logic of the dish) (Note: the two words encapsulated in the screenshot are wrong and become crazy)
Change the Toast of the SeekBar and add it to be called at the end of the drag, so that the display time is not so long.
Add listeners for toggleButton looking for buttons and show
Do the rest of the functions yourself
Summarize: