guys! I am having a problem with for cycle.So i have a for() that goes through every value of third column from database(which is supposed to be in date format).I want to change the background color of an item from listview if the month of the added date is the same as the current month.The problem is there - if i use the code like this:
public void setItemRed(View view){
for(int i = 0 ; i <= myDB.getLastID() ; i++){
String date = myDB.getcol3(i);
String day = date.substring(0 , 2);
String month = date.substring(3 , 5);
String currentDate = currentDate();
String currentMonth = currentDate.substring(3 , 5);
listView.getChildAt(i).setBackgroundColor(Color.RED);
}
}
Everything works and every item gets red background.But when i add if :
public void setItemRed(View view){
for(int i = 0 ; i <= myDB.getLastID() ; i++){
String date = myDB.getcol3(i);
String day = date.substring(0 , 2);
String month = date.substring(3 , 5);
String currentDate = currentDate();
String currentMonth = currentDate.substring(3 , 5);
if(date.length() == 10){
if(month == currentMonth) {
listView.getChildAt(i).setBackgroundColor(Color.RED);
}
}
}
}
It does not work.Thank you in advance!