At the moment i have two list one i made it myself and the other one is from Parse.
First List...
public static List<String> getHoraDia(){
List<String> list = new ArrayList<>();
list.add("05:00am");
list.add("05:30am");
list.add("06:00am");
list.add("06:30am");
list.add("07:00am");
list.add("07:30am");
list.add("08:00am");
list.add("08:30am");
list.add("09:00am");
list.add("09:30am");
list.add("10:00am");
list.add("10:30am");
list.add("11:00am");
list.add("11:30am");
list.add("12:00am");
list.add("12:30am");
list.add("1:00pm");
list.add("1:30pm");
list.add("2:00pm");
list.add("2:30pm");
list.add("3:00pm");
list.add("3:30pm");
list.add("4:00pm");
list.add("4:30pm");
list.add("5:00pm");
list.add("5:30pm");
return list;
}
}
The other list has 8:00am and 9:30am there comes my first question can i compare list with different sizes???.
This is what im thinking at the moment ..
int contador = 0;
for (String horas : horasList) {
Log.i("HORA","este es horas"+horas);
for (ParseObject citas : citasTaller) {
String horaCita = citas.getString("Hora");
Log.i("HORA","este es horasCita"+horaCita);
if(horas.equals(horaCita)){
}
contador++;
}
}
Haven't figure out what to put in the if statement ..
My goal is to accomplish that if the String is in horasList and in citasTaller
to be erased from a Spinner. Which i accomplished putting a random position into this...
horasList.remove(3);
adapter.notifyDataSetChanged();
So it should go something like
horasList.remove(horaCita)
There's gotta be a better way to do this. In this order of ideas i need to delete from horasList the 8:00am and the 9:30am.
By the way i made this..
horasList = UtilAppFuntions.getHoraDia();
This is the update of the code corresponding to answers...
So i did this but i have a problem @muasif80 once the hour is equal to the string the index is removed and the list is also removed in 1 so the index changes for every value..
ParseQuery<ParseObject> query = ParseQuery.getQuery("CitaTaller");
qEmp=ParseObject.createWithoutData("Empresa",objIdEmpresa);
query.whereEqualTo("Empresa",qEmp);
query.whereEqualTo("fecha", fechaSeleccionada);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> objects, ParseException e) {
if (e == null) {
for (ParseObject obj : objects) {
String hora=obj.getString("Hora");
citasTaller.add(obj);
int listSize = citasTaller.size();
for (int i = 0; i < listSize; i++) {
Log.i("JOHI", String.valueOf(citasTaller.get(i)));
}
}
adapter =
new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, horasList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sphorasdia.setAdapter(adapter);
for(ParseObject parseObject : citasTaller){
String hora = parseObject.getString("Hora");
if(hora.equals("05:00am")){
horasList.remove(0);
adapter.notifyDataSetChanged();
}
if(hora.equals("05:30am")){
horasList.remove(1);
adapter.notifyDataSetChanged();
}
if(hora.equals("06:00am")) {
horasList.remove(2);
adapter.notifyDataSetChanged();
}
if (hora.equals("6:30am")){
horasList.remove(3);
adapter.notifyDataSetChanged();
}
if(hora.equals("7:00am")){
horasList.remove(4);
adapter.notifyDataSetChanged();
}
if(hora.equals("7:30am")){
horasList.remove(5);
adapter.notifyDataSetChanged();
}
if(hora.equals("8:00am")){
horasList.remove(6);
adapter.notifyDataSetChanged();
}
if(hora.equals("8:30am")){
horasList.remove(7);
adapter.notifyDataSetChanged();
}
if(hora.equals("9:00am")){
horasList.remove(8);
adapter.notifyDataSetChanged();
}
if(hora.equals("9:30am")){
horasList.remove(9);
adapter.notifyDataSetChanged();
}
if(hora.equals("10:00am")){
horasList.remove(10);
adapter.notifyDataSetChanged();
}
if(hora.equals("10:30am")){
horasList.remove(11);
adapter.notifyDataSetChanged();
}
if(hora.equals("11:00am")){
horasList.remove(12);
adapter.notifyDataSetChanged();
}
if(hora.equals("11:30am")){
horasList.remove(13);
adapter.notifyDataSetChanged();
}
if(hora.equals("12:00pm")){
horasList.remove(14);
adapter.notifyDataSetChanged();
}
if(hora.equals("12:30pm")){
horasList.remove(15);
adapter.notifyDataSetChanged();
}
if(hora.equals("1:00pm")){
horasList.remove(16);
adapter.notifyDataSetChanged();
}
if(hora.equals("1:30pm")){
horasList.remove(17);
adapter.notifyDataSetChanged();
}
if(hora.equals("2:00pm")){
horasList.remove(18);
adapter.notifyDataSetChanged();
}
if(hora.equals("2:30pm")){
horasList.remove(19);
adapter.notifyDataSetChanged();
}
if(hora.equals("3:00pm")){
horasList.remove(20);
adapter.notifyDataSetChanged();
}
if(hora.equals("3:30pm")){
horasList.remove(21);
adapter.notifyDataSetChanged();
}
if(hora.equals("4:00pm")){
horasList.remove(22);
adapter.notifyDataSetChanged();
}
if(hora.equals("4:30pm")){
horasList.remove(23);
adapter.notifyDataSetChanged();
}
if(hora.equals("5:00pm")){
horasList.remove(24);
adapter.notifyDataSetChanged();
}
if(hora.equals("5:30pm")){
horasList.remove(25);
adapter.notifyDataSetChanged();
}
if(hora.equals("6:00pm")){
horasList.remove(26);
adapter.notifyDataSetChanged();
}
}
} else {
Log.d("score", "Error: " + e.getMessage());
}
}
});