Package com.example.iconic_raffleevent
Class EventAdapter
java.lang.Object
android.widget.BaseAdapter
android.widget.ArrayAdapter<Event>
com.example.iconic_raffleevent.EventAdapter
- All Implemented Interfaces:
android.widget.Adapter
,android.widget.Filterable
,android.widget.ListAdapter
,android.widget.SpinnerAdapter
,android.widget.ThemedSpinnerAdapter
Custom ArrayAdapter for displaying a list of Event objects in a ListView.
Populates each item view with an event's image, title, date, and optionally displays
an icon for managing the event if the current user is the event organizer.
-
Field Summary
Fields inherited from interface android.widget.Adapter
IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
-
Constructor Summary
ConstructorsConstructorDescriptionEventAdapter
(android.content.Context context, List<Event> eventList, String currentUserId) Constructs a new EventAdapter. -
Method Summary
Modifier and TypeMethodDescriptionandroid.view.View
getView
(int position, android.view.View convertView, android.view.ViewGroup parent) Returns a View for an Event item in the ListView.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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface android.widget.Adapter
getItemViewType, getViewTypeCount, hasStableIds, isEmpty, registerDataSetObserver, unregisterDataSetObserver
-
Constructor Details
-
EventAdapter
Constructs a new EventAdapter.- Parameters:
context
- The context in which the adapter is created.eventList
- The list of Event objects to be displayed.currentUserId
- The ID of the current user, used to determine if the user is the event organizer.
-
-
Method Details
-
getView
@NonNull public android.view.View getView(int position, android.view.View convertView, android.view.ViewGroup parent) Returns a View for an Event item in the ListView. Inflates the item layout if necessary, and sets the event image, title, date, and shows or hides the manage event icon based on the user's role.- Specified by:
getView
in interfaceandroid.widget.Adapter
- Overrides:
getView
in classandroid.widget.ArrayAdapter<Event>
- Parameters:
position
- The position of the item within the adapter's data set.convertView
- The old view to reuse, if possible.parent
- The parent ViewGroup that is used to inflate the new view.- Returns:
- The View for the specified position.
-