Package com.example.cardiotracker
Class HealthDataAdapter
java.lang.Object
android.widget.BaseAdapter
android.widget.ArrayAdapter<HealthData>
com.example.cardiotracker.HealthDataAdapter
- All Implemented Interfaces:
android.widget.Adapter
,android.widget.Filterable
,android.widget.ListAdapter
,android.widget.SpinnerAdapter
,android.widget.ThemedSpinnerAdapter
The HealthDataAdapter is a custom ArrayAdapter used to populate a ListView with HealthData objects.
It handles the creation of the list item views and displays the health data information in the appropriate views.
-
Field Summary
Fields inherited from interface android.widget.Adapter
IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
-
Constructor Summary
ConstructorsConstructorDescriptionHealthDataAdapter
(android.content.Context context, List<HealthData> dataList) Constructs a HealthDataAdapter with the given context and data list. -
Method Summary
Modifier and TypeMethodDescriptionprivate String
formatTime
(String time) Formats the given time string into the desired format.android.view.View
getView
(int position, android.view.View convertView, android.view.ViewGroup parent) Gets a View that displays the data at the specified position in the data list.Methods inherited from class android.widget.ArrayAdapter
add, addAll, addAll, clear, createFromResource, getAutofillOptions, getContext, getCount, getDropDownView, getDropDownViewTheme, getFilter, getItem, getItemId, getPosition, insert, notifyDataSetChanged, remove, setDropDownViewResource, setDropDownViewTheme, setNotifyOnChange, sort
Methods inherited from class android.widget.BaseAdapter
areAllItemsEnabled, getItemViewType, getViewTypeCount, hasStableIds, isEmpty, isEnabled, notifyDataSetInvalidated, registerDataSetObserver, setAutofillOptions, unregisterDataSetObserver
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface android.widget.Adapter
getItemViewType, getViewTypeCount, hasStableIds, isEmpty, registerDataSetObserver, unregisterDataSetObserver
-
Constructor Details
-
HealthDataAdapter
Constructs a HealthDataAdapter with the given context and data list.- Parameters:
context
- the context of the adapterdataList
- the list of HealthData objects to be displayed
-
-
Method Details
-
getView
public android.view.View getView(int position, android.view.View convertView, android.view.ViewGroup parent) Gets a View that displays the data at the specified position in the data list.- Specified by:
getView
in interfaceandroid.widget.Adapter
- Overrides:
getView
in classandroid.widget.ArrayAdapter<HealthData>
- Parameters:
position
- the position of the item within the adapter's data setconvertView
- the old view to reuse, if possibleparent
- the parent ViewGroup containing the convertView- Returns:
- the View corresponding to the data at the specified position
-
formatTime
Formats the given time string into the desired format.- Parameters:
time
- the time string to be formatted- Returns:
- the formatted time string
-