title: Receive a long press/click on a linear layout in android?
body: <p>I'm painfully new to android and I've run into a wall.</p>
  
  <p>I'm trying get a linear layout to function more like a button, with different actions for press and long press - The reason being so I can have 2 differently formatted text labels on each "button". Something along the lines of:</p>
  
  <pre><code>-------------------------
  |          2nd          |  &lt;- Label for long press (regular/smaller type)
  |           =           |  &lt;- Label for regular press (bold/larger type)
  -------------------------
  </code></pre>
  
  <p>The posts I've found explain how to receive a regular click on a linear layout (I use the onClick attribute in the layout XML). But I've had no luck with long press. I've tried to define a new onLongClick attribute for xml as described in Aleksander Gralak's answer here: <a href="https://stackoverflow.com/questions/5706038/long-press-definition-at-xml-layout-like-androidonclick-does">Long press definition at XML layout, like android:onClick does</a> . But had no such luck - it looks like it was intended for a text view, I tried changing it to linear layout but failed miserably.</p>
  
  <p>Here is the object in question: <code>Main.xml</code></p>
  
  <pre><code>&lt;LinearLayout
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:gravity="center"
      android:clickable="true"
      android:focusable="true"
      android:background="@drawable/darkgrey_button"
      android:onClick="equals" android:longClickable="true" android:id="equalsbutton"
      android:focusableInTouchMode="false"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="2nd"
          android:id="@+id/textView"
          android:duplicateParentState="true"/&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text=" = "
          android:id="@+id/textView1"
          android:duplicateParentState="true"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And <code>Main.java</code></p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  }
  
  public void equals(View view) {
      Context context = getApplicationContext();
      CharSequence text = "Hello toast!";
      int duration = Toast.LENGTH_SHORT;
  
      Toast toast = Toast.makeText(context, text, duration);
      toast.show();
  }
  </code></pre>