Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Check a sample code for onclicklistener for images......!!!!!</p> <p>Java Class:-</p> <pre><code>public OnClickListener onclickimage = new OnClickListener() { @Override public void onClick(View v) { switch (v.getId()) { case R.id.imageView1: rlayout.setBackgroundResource(R.drawable.bg); break; case R.id.imageView2: rlayout.setBackgroundResource(R.drawable.bg_evening); break; case R.id.imageView3: rlayout.setBackgroundResource(R.drawable.bg_morning); break; case R.id.imageView4: rlayout.setBackgroundResource(R.drawable.bg_night); break; } } }; @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } </code></pre> <p>And Layout Code :-</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/rlayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" &gt; &lt;ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:src="@drawable/ic_launcher" /&gt; &lt;ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/imageView1" android:src="@drawable/ic_launcher" /&gt; &lt;ImageView android:id="@+id/imageView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/imageView2" android:src="@drawable/ic_launcher" /&gt; &lt;ImageView android:id="@+id/imageView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/imageView3" android:src="@drawable/ic_launcher" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>May this Answer can help you.....!!!!!!</p> <p>You can do the same for ur loop images...!!!!!</p> <p>Or u Can use theme for the following..!!!!</p> <p>Sry if i not complete ur any another requirement..!!!</p>
 

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