I have compass in my adapter, and my SensorEventListener is in my activity. According to SensorEventListener, I am updating my listview by using the value and notifydatasetchanged(). It works perfectly for compass, but because I am continuously updating my listview, I cannot click on listitem. Do you have any suggestion? Here is my code...
Activity .....
....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) {
}
};....
Adapter ........
@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();
}