-2

Hi in the below code mandatoryCount = 0 and it should be increased when an image is selected but its found to be always 1 and i cant exit the loop can any one help me. 这里如果mandatoryCount = 0 或mandatoryCount>=imageTypeMandatory.length。它必须脱离循环。但是,如果我注释强制计数 ==0,则此代码有效。我找不到确切的错误。

if (dataOne.getCount() >= 1) {
mandatoryCount=0;                                   
dataOne.moveToFirst();             
while(!dataOne.isAfterLast()){                                  
for(int iCopy=0;iCopy<imageTypeMandatory.length;iCopy++){                               if(imageTypeMandatory[iCopy].trim().equalsIgnoreCase(dataOne.getString(0).trim())){
mandatoryCount++;                               imageTypeMandatoryCopy[iCopy]="";
}}          
dataOne.moveToNext();
}
4

1 回答 1

0

逻辑是测试 moveFirst/moveNext。

if (dataOne.moveToFirst()) {
    do {
        for(int iCopy=0;iCopy<imageTypeMandatory.length;iCopy++){
            if(imageTypeMandatory[iCopy].trim().equalsIgnoreCase(dataOne.getString(0).trim())){
                mandatoryCount++;
                imageTypeMandatoryCopy[iCopy]="";
            }   
        }
    } while(dataOne.moveToNext());
}
于 2013-08-07T08:36:49.967 回答