我有一个网格视图,由一个自定义适配器(下面)填充。所以我将一个对象的数组列表传递给适配器,测试结果。测试结果基于每个对象中的变量。因此,例如,如果对象类型为x,则检查y == 1,如果是,则通过等...我的逻辑包含在下面。我的结果表明我有5个失败,并且从我的五个列表中有2个过程,但是,即使在五个网格项中显示正确的id,也会显示不正确的图标和背景。另外,如果你看一下logcat的底部,它表明有26个通过,39个失败了?
有人可以指出我在哪里出错。谢谢!
package adapters;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import rjg.momentum.com.websockets.SharedDefinitions.SensorResult;
public class SensorTestResultAdapter extends ArrayAdapter<SensorResult> {
private static final String m_Tag = SensorTestResultAdapter.class.getSimpleName();
private static final String SENSOR1 = "sensor1";
private static final String SENSOR2 = "sensor2";
private Context mContext;
public int mPassed;
public int mWarning;
public int mFailed;
//will be initialised to current sensor list passed in constructor
private ArrayList<SensorResult> mSensorResultList;
public SensorTestResultAdapter(Context context, ArrayList<SensorResult> sensorResultList){
super(context, R.layout.sensor_test_result_grid_item, sensorResultList);
this.mContext = context;
this.mSensorResultList = sensorResultList;
this.mWarning = 0;
this.mFailed = 0;
this.mPassed = 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
//SensorHolder
SensorHolder holder = null;
//Inflater to inflate the list item
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//Inflating the list item view
View view = convertView;
if(view==null){
view = inflater.inflate(R.layout.sensor_test_result_grid_item, parent, false);
}
holder = new SensorHolder();
holder.icon = (ImageView)view.findViewById(R.id.status_icon);
holder.id = (TextView)view.findViewById(R.id.sensor_id);
holder.id.setText(mSensorResultList.get(position).getSensorId());
Log.i(m_Tag, "List Size: " + mSensorResultList.size());
for(SensorResult result:mSensorResultList){
String sensorType = result.getSensorType();
if(sensorType.equals(SENSOR1)) {
int driftResult = result.getDriftResult();
Log.i(m_Tag, "SENSOR1");
if (driftResult == 0 && result.getComResult() == 0) {
Log.i(m_Tag, "Sensor Passed");
mPassed+=1;
holder.gridBackground.setBackground(mContext.getResources().getDrawable(R.drawable.bkg_sensor_passed));
holder.icon.setBackground(mContext.getResources().getDrawable(R.drawable.ic_passed));
} else if (driftResult == 1) {
Log.i(m_Tag, "Drift Result Alert");
mWarning+=1;
holder.gridBackground.setBackground(mContext.getResources().getDrawable(R.drawable.bkg_sensor_warning));
holder.icon.setBackground(mContext.getResources().getDrawable(R.drawable.ic_warning));
} else if (driftResult == 2 || (result.getComResult() != 0)) {
Log.i(m_Tag, "Sensor Failed");
mFailed+=1;
holder.gridBackground.setBackground(mContext.getResources().getDrawable(R.drawable.bkg_sensor_alert));
holder.icon.setBackground(mContext.getResources().getDrawable(R.drawable.ic_alert));
}
}else if(sensorType.equals(SENSOR2)){
Log.i(m_Tag, "SENSOR2");
int zeroShiftResult = result.getZeroShiftResult();
//Log.i(m_Tag, "Zero shift result: " + String.valueOf(zeroShiftResult));
if(zeroShiftResult==0 && result.getComResult()==0 && result.getGaugeResult()==0){
Log.i(m_Tag, "Sensor Passed");
mPassed+=1;
holder.gridBackground.setBackground(mContext.getResources().getDrawable(R.drawable.bkg_sensor_passed));
holder.icon.setBackground(mContext.getResources().getDrawable(R.drawable.ic_passed));
}else if(zeroShiftResult==1){
Log.i(m_Tag, "Zero shift Result Alert");
mWarning+=1;
holder.gridBackground.setBackground(mContext.getResources().getDrawable(R.drawable.bkg_sensor_warning));
holder.icon.setBackground(mContext.getResources().getDrawable(R.drawable.ic_warning));
}else if(zeroShiftResult==2 || result.getComResult()!=0){
Log.i(m_Tag, "Sensor Failed");
mFailed +=1;
holder.gridBackground.setBackground(mContext.getResources().getDrawable(R.drawable.bkg_sensor_alert));
holder.icon.setBackground(mContext.getResources().getDrawable(R.drawable.ic_alert));
}
}
}
Log.i(m_Tag, "Passed: "+ String.valueOf(mPassed));
Log.i(m_Tag, "Warning: "+String.valueOf(mWarning));
Log.i(m_Tag, "Failed: "+String.valueOf(mFailed));
//Return the view;
return view;
}
static class SensorHolder{
ImageView icon;
TextView id;
RelativeLayout gridBackground;
}
/**
*
* @return
*/
public int getPassedAmount(){return this.mPassed;}
public int getWarningAmount(){return this.mWarning;}
public int getFailedAmount(){return this.mFailed;}
}
这是我的logcat:
02-25 16:19:29.730 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 2
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 3
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.740 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕SENSOR2
02-25 16:19:29.750 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.750 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.750 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.750 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR
02-25 16:19:29.750 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.750 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 4
02-25 16:19:29.750 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.750 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 6
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 6
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 9
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 8
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 12
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.780 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕SENSOR1
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 10
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 15
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕SENSOR2
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 12
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.790 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 18
02-25 16:19:29.810 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.810 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.810 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕SENSOR1
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 14
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 21
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 16
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.820 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 24
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 18
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 27
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕SENSOR2
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕SENSOR1
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 20
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.830 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 30
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕SENSOR1
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 22
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 33
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 24
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 36
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ List Size: 5
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.840 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.850 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.850 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Failed
02-25 16:19:29.850 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR2
02-25 16:19:29.850 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.850 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ SENSOR1
02-25 16:19:29.850 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Sensor Passed
02-25 16:19:29.850 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Passed: 26
02-25 16:19:29.850 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Warning: 0
02-25 16:19:29.850 31599-31599/rjg.momentum.com.rjgsensortest I/SensorTestResultAdapter﹕ Failed: 39
答案 0 :(得分:1)
如果我理解正确,那么我认为问题是你每次调用getView()方法时都在处理(迭代)所有结果,而不是你想要的单个结果。
而不是
for(SensorResult result:mSensorResultList){
String sensorType = result.getSensorType();
...
尝试字符串
sensorType = mSensorResultList.get(position).getSensorType();