public static boolean addReminder(Activity activity,View view,View.OnClickListener listener,ArrayList<LinearLayout> items,ArrayList<Integer> minuteValues,ArrayList<String> minuteLabels,ArrayList<Integer> methodValues,ArrayList<String> methodLabels,ReminderEntry newReminder,int maxReminders,OnItemSelectedListener onItemSelected){
  if (items.size() >= maxReminders) {
    return false;
  }
  LayoutInflater inflater=activity.getLayoutInflater();
  LinearLayout parent=(LinearLayout)view.findViewById(R.id.reminder_items_container);
  LinearLayout reminderItem=(LinearLayout)inflater.inflate(R.layout.edit_reminder_item,null);
  parent.addView(reminderItem);
  ImageButton reminderRemoveButton;
  reminderRemoveButton=(ImageButton)reminderItem.findViewById(R.id.reminder_remove);
  reminderRemoveButton.setOnClickListener(listener);
  Spinner spinner=(Spinner)reminderItem.findViewById(R.id.reminder_minutes_value);
  setReminderSpinnerLabels(activity,spinner,minuteLabels);
  int index=findMinutesInReminderList(minuteValues,newReminder.getMinutes());
  spinner.setSelection(index);
  if (onItemSelected != null) {
    spinner.setTag(index);
    spinner.setOnItemSelectedListener(onItemSelected);
  }
  spinner=(Spinner)reminderItem.findViewById(R.id.reminder_method_value);
  setReminderSpinnerLabels(activity,spinner,methodLabels);
  index=findMethodInReminderList(methodValues,newReminder.getMethod());
  spinner.setSelection(index);
  if (onItemSelected != null) {
    spinner.setTag(index);
    spinner.setOnItemSelectedListener(onItemSelected);
  }
  items.add(reminderItem);
  return true;
}

public static boolean addReminder ( Activity activity , View view , View . OnClickListener listener , ArrayList < LinearLayout > items , ArrayList < Integer > minuteValues , ArrayList < String > minuteLabels , ArrayList < Integer > methodValues , ArrayList < String > methodLabels , ReminderEntry newReminder , int maxReminders , OnItemSelectedListener onItemSelected ) { if ( items . size ( ) >= maxReminders ) { return false ; } LayoutInflater inflater = activity . getLayoutInflater ( ) ; LinearLayout parent = ( LinearLayout ) view . findViewById ( R . id . reminder_items_container ) ; LinearLayout reminderItem = ( LinearLayout ) inflater . inflate ( R . layout . edit_reminder_item , null ) ; parent . addView ( reminderItem ) ; ImageButton reminderRemoveButton ; reminderRemoveButton = ( ImageButton ) reminderItem . findViewById ( R . id . reminder_remove ) ; reminderRemoveButton . setOnClickListener ( listener ) ; Spinner spinner = ( Spinner ) reminderItem . findViewById ( R . id . reminder_minutes_value ) ; setReminderSpinnerLabels ( activity , spinner , minuteLabels ) ; int index = findMinutesInReminderList ( minuteValues , newReminder . getMinutes ( ) ) ; spinner . setSelection ( index ) ; if ( onItemSelected != null ) { spinner . setTag ( index ) ; spinner . setOnItemSelectedListener ( onItemSelected ) ; } spinner = ( Spinner ) reminderItem . findViewById ( R . id . reminder_method_value ) ; setReminderSpinnerLabels ( activity , spinner , methodLabels ) ; index = findMethodInReminderList ( methodValues , newReminder . getMethod ( ) ) ; spinner . setSelection ( index ) ; if ( onItemSelected != null ) { spinner . setTag ( index ) ; spinner . setOnItemSelectedListener ( onItemSelected ) ; } items . add ( reminderItem ) ; return true ; }
adds a reminder to the displayed list of reminders . the values / labels arrays must not change after calling here , or the spinners we created might index into the wrong entry . returns true if successfully added reminder , false if no reminders can be added . onitemselected allows a listener to be set for any changes to the spinners in the reminder . if a listener is set it will store the initial position of the spinner into the spinner ' s tag for comparison with any new position setting .
