0
나는 쉼표로 구분 된 문자열 형식으로 데이터베이스에서 위치 이름을 가져옵니다. 이 문자열을 입력 된 위치 이름이 데이터베이스에있는 위치 이름과 같은지 확인하기 위해 입력 한 위치 이름이 들어있는 문자열의 ArrayList와 비교합니다. 이렇게하려면 아래 코드를 사용하고 있습니다. 그러나 그것은 효과가없는 것처럼 보입니다. 친절하게 내가 그것에 대해 어떻게 할 수 있는지 알려주세요. 나는 equals()도 사용했지만 잘 동작하지 않습니다.안드로이드 : 문자열의 arraylist와 쉼표로 구분 된 문자열을 비교하십시오.
String loc =DataHelperdh.getLocationList(id); // loc holds the comma separated locations
for (int i2 = 0; i2 < locationList.size(); i2++)
{
if(locationList.get(i2)==null || locationList.get(i2).equals(""))continue;
String str1 =loc.toString();
int result = str1.indexOf(locationList.get(i2));
if(result > -1){
Toast.makeText(getApplicationContext(), "Locations with same name cannot exist same", Toast.LENGTH_LONG).show();
break;
}
}