Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Seems to work for me like this, </p> <p>Your xml file, </p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;LinearLayout android:id="@+id/btn1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" &gt; &lt;ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /&gt; &lt;TextView android:layout_width="150dp" android:layout_height="fill_parent" android:gravity="center_vertical" android:text="something" /&gt; &lt;Button android:id="@+id/btn" android:text="Button" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p>And your Activity class, </p> <pre><code>public class MainActivity extends Activity implements OnClickListener{ LinearLayout btn1 =null; Button btn =null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn1 = (LinearLayout) findViewById(R.id.btn1); btn1.setOnClickListener(this); btn = (Button) findViewById(R.id.btn); btn.setOnClickListener(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } public void onClick(View v) { if(v==btn) { Toast.makeText(getApplicationContext(), "btn clicked", Toast.LENGTH_SHORT).show(); } if(v==btn1) { Toast.makeText(getApplicationContext(), "btn1 clicked", Toast.LENGTH_SHORT).show(); } } } </code></pre> <p><img src="https://i.stack.imgur.com/WHuZg.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/rTQWL.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload