2
I have a problem that I don’t understand because here’s the thing: When I go to add an item to the list, it has to check if that item is already in the list but it is not doing that.
if(textNameD.getText().length() > 0 && textNota.getText().length() > 0) {
String nameD = textNameD.getText().toString();
for (int i = 0; i < list.size();i++){
listItem item = list.get(i);
Log.d("D","1 ."+nameD+". | ."+item.name+".");
if (item.name == nameD) {
Log.d("D","2");
showNotificacion(view,"A disciplina "+item.name+" já existe!");
return;
}
Log.d("D","3");
}
Log.d("D","4");
add(textNameD.getText().toString(),stringToInt(textNota.getText().toString()));
textNameD.setText("");
textNota.setText("");
}else {
showNotificacion(view,"Preenche todos os espacos!");
}
And you’re getting the following in the log:
D/D: 1 .gg. | . Gg.
D/D: 3
D/D: 4
The check is receiving that item.name=Gg and named=Gg but it is not passing to if, it is jumping to log 3.
If anyone knows how to solve or do another trick I’d appreciate it:)