Reputation: 107
So my app has spinners that can be dynamically added and they are being populated from a huge array list of Course
objects like so
courseSpinner = rowView.findViewById(R.id.first_spinner);
ArrayAdapter<Course> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, courseList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
courseSpinner.setAdapter(adapter);
parentLayout.addView(rowView, parentLayout.getChildCount() - 1);
allSpinners.add(courseSpinner); //this is an ArrayList of spinners that keeps track of how many spinners exist currently since like mentioned before they can be dynamically added or removed
I want to remove the values that are selected after a button is pressed from each newely generated spinner. The button when pressed saves the values to a seperate hash map and deletes all existing spinners but I need to implement some sort of update method that will be called that will repopulate or subtract values from the courseList
where spinners takle their values from. Any help is appreciated
Upvotes: 0
Views: 42
Reputation: 188
This is your spinner with adapter and list :
ArrayAdapter<String> arrayAdapter;
arrayAdapter= new ArrayAdapter<String>(this, R.layout.spinner_indication, yourList);
Spinner yourSpinner;
yourSpinner.setAdapter(arrayAdapter)
your new List created from your old one set it to the adapter like this :
yourList = newGeneratedList ;
arrayAdapet.notifyDataSetChanged();
Upvotes: 2