I have made a custom ArrayAdapter,I am getting an arrayList in taht adapter,I want to put a condition that two values from arrayList(payer_id and Payee_id) are equal or not,If equal print "equal",Else "Not qual"..My Code is as below:but its all time goes to not equal condition..Please help me save me. code
public ArrayList<HashMap<String, String>> receivePaymentArray;
if (receivePaymentArray.get(paramInt).get(Const.TAG_PAYEE_ID).equalsIgnoreCase(receivePaymentArray.get(paramInt).get(Const.TAG_PAYER_ID))) {
System.out.println("::::::::::::::::::::::SAME IDS::::::::::::::::");
} else {
System.out.println("::::::::::::::::::::::different ids:::::::::::::::");
}
Are the variables you are comparing strings or integers.. id s are usually int but your question implies they are strings..
Strings compared using == will always return false because they are not the same object.. with strings you have to use '.equals("something")
As you say they are strings try doing
get(Const.TAG_PAYEE_ID).toString().trim().equals(get(Const.TAG_PAYEE_ID).toString().trim())
might solve your issue. Just added .toString().trim() to both parameters get statements.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.