title: How do you implement action listener on listView?
body: <p>I have been struggling for days trying to find the proper way to implement an action listener to a ListView. What I really want to accomplish is to create a ListView and whenever the user clicks any item, the previous Activity will be switched. I am really new at this so please help me, I would really appreciate it a lot. If you can tell me the what I'm doing wrong on my code that would be awesome!</p>
  
  <p>I am using Fedor's code from [here][1].</p>
  
  <pre><code>        ///Here I tried to Implement an action listener but It doesn't work.
  
          list.setOnItemClickListener(new OnItemClickListener() {                                                                                                                                                             
              public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position,long id)                               
              {                                                                                                                                                                           
                  if(list.getItemAtPosition(position).equals(mStrings[1]))                                                       
                  {                                                                                                           
                      Intent i = new Intent(MainActivity.this, Activity2.class);                                                                                        
                      startActivity(i);                                                                                
                      }                                                                                                    
                  }                                                                                                       
              });
  
  
        }
  </code></pre>