title: When the sensor event is changed, the ListItem Click event does not fire or responding very slow
body: <p>I have an application, on which when device is rotated, i.e., when onSensorChanged(), I am trying to display a ListView with some dynamic data populated in it through a custom list adapter. When the device is rotated, the data in the ListView is to be updated in the ListView dynamically accordingly. I am able to generate dynamic data but when clicked on ListItem, the click event does not seem to be recognised.</p>
  
  <p>Why is this happening? When the ListItem is clicked, I want to perform another activity which elaborates the clicked List Item's data.</p>
  
  <p>This is my code,</p>
  
  <pre><code> public void onSensorChanged(SensorEvent event) {
      TextView txtangle = (TextView) findViewById(R.id.txtangle);
      if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
  
          // Log.v("ACCELEROMETER", "ACCELEROMETER");
  
          mGravity = event.values;
  
      }
  
      if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
  
          // Log.v("MAGNETIC_FIELD", "MAGNETIC_FIELD");
  
          mGeomagnetic = event.values;
  
      }
  
      if (mGravity != null &amp;&amp; mGeomagnetic != null) {
  
          float first[] = new float[9];
  
          float second[] = new float[9];
  
          boolean success = SensorManager.getRotationMatrix(first, second,
                  mGravity, mGeomagnetic);
  
          if (success) {
  
              float orientation[] = new float[3];
  
              SensorManager.getOrientation(first, orientation);
  
              azimuth = orientation[0]; // orientation contains: azimut, pitch
                                          // and roll
          }
      }
      mycallback(event);
    }
  
    public void mycallback(SensorEvent event) {
  
      ListView propertylistview = (ListView) findViewById(R.id.listview);
      PropertiesArray = new ArrayList&lt;Propety&gt;(4);
      PropertiesArray.add(new Propety("Banjara Hills",
              "Price: 100000"));
      PropertiesArray.add(new Propety("Jubilee Hills",
              "Price: 200000"));
      PropertiesArray.add(new Propety("Film Nagar", "Price: 70000"));
      PropertiesArray.add(new Propety("Kukatpally", "Price: 50000"));
      PropertiesArray.add(new Propety("Jubilee Hills",
              "Price: 200000"));
      PropertiesArray.add(new Propety("Film Nagar", "Price: 70000"));
       customadapter customlistview = new customadapter(
              PropertiesArray); // customadapter is the Custom List Adapter
      propertylistview.setAdapter(customlistview);
  
  }   //This is the hardcoded data. 
  </code></pre>
  
  <p>my customadapter class,</p>
  
  <pre><code> public class customadapter extends BaseAdapter {
  LayoutInflater inflater;
  ArrayList&lt;Propety&gt; PropertiesArray;
  
  public customadapter(ArrayList&lt;Propety&gt; PropertiesArray) {  
  
     this.PropertiesArray=PropertiesArray;
  
  }
  @Override
  public int getCount() {
  
      return PropertiesArray.size();
  }
  
  @Override
  public Object getItem(int position) {
  
      return PropertiesArray.get(position);
  }
  
  @Override
  public long getItemId(int position) {
      // TODO Auto-generated method stub
      return position;
  }
  
  @Override
  public View getView(final int position, View View, final ViewGroup parent) {
  
       if (View == null) {
              LayoutInflater inflater = LayoutInflater.from(parent.getContext());
              View = inflater.inflate(R.layout.customlistview, parent, false);
          }
        final Propety ListArray = PropertiesArray.get(position);
        TextView tvPropertyName = (TextView) View.findViewById(R.id.tvCity);
         tvPropertyName.setText(ListArray.getName());
  
          TextView tvPrice = (TextView) View.findViewById(R.id.tvprice);
          tvPrice.setText(ListArray.getPrice());
  
         ImageView imgProperty = (ImageView) View.findViewById(R.id.list_image);
         imgProperty.setImageResource(R.drawable.ic_launcher);
  
         View.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
              Toast.makeText(parent.getContext(), "view clicked: "+ ListArray.getName(), Toast.LENGTH_SHORT).show();
  
          }   // This is not firing. Toast is not being displayed. 
      });
      return View;
  }
  
  }
  </code></pre>
  
  <p>I want this data to be updated whenever the sensor is changed or the device is rotated. But this seems to be an Incorrect Implementation.</p>
  
  <p>Can anyone please correct me or suggest a good method. I am a newbie to android. 
    This is very hard to me!! 
    Any help will be appreciated.</p>