title: how to handle long click in Android
body: <p>I am new to Android dev.  The way I have been handling clicks has been by setting the <code>android:onClick</code> attribute in the manifest file for buttons.  What I am wondering is the best way to handle long clicks in general.  I have read about implementing <code>onLongClick()</code>, but is there a way to use handlers (like above), rather than having to extend View?  It would be very helpful, as I would rather not have to rebuild my entire project with an extended View class.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I should clarify.  I have a <code>ListView</code> and I want to set what will happen when I long click on an element in the list.  Each element in the list is a <code>TextView</code>.  As per one of the answers, I have added the below code, and now I get a force close:</p>
  
  <pre><code>public class TwitterActivity extends ListActivity {
      List&lt;String&gt; tweets = new LinkedList&lt;String&gt;();
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
  
              setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.layout, tweets));
  
              TextView view = (TextView) findViewById(R.id.ListTemplate);
              view.setOnLongClickListener(new OnLongClickListener() {
                  @Override
                  public boolean onLongClick(View v) {
                      Toast toast = new Toast(TwitterActivity.this);
                      toast.setText("LongClick");
                      toast.show();
  
                      return true;
                  }
              });
  
      //...
      }
  }
  </code></pre>