我的适配器中有指南针,SensorEventListener
我的活动在我的活动中。根据SensorEventListener
,我正在listview
使用该值更新我的值,notifydatasetchanged().
它非常适用于指南针,但是因为我不断更新我的列表视图,所以我无法单击listitem
。你有什么建议吗?这是我的代码...
活动 .....
....listener = new SensorEventListener() {
public void onSensorChanged(SensorEvent event) {
float[] values = event.values;
((ParkedCarsListAdapter) listParkedCars.getAdapter()).updateCompass(-values[0]);
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
};....
适配器 ........
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(cars.get(position).getNorth()!=0){
compass.setNorth(cars.get(position).getNorth());
}
.......
}
...public void updateCompass(float northvalue) {
for (Car car : cars) {
car.setNorth(northvalue);
}
this.notifyDataSetChanged();
}