画像の onclicklistener のサンプル コードを確認してください......!!!!!
Java クラス:-
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;
}
}
そしてレイアウトコード:-
<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" >
<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" />
<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" />
<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" />
<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" />
</RelativeLayout>
この回答が役に立ちますように.....!!!!!!!!
ループ画像についても同じことができます...!!!!!
または、次のテーマを使用できます..!!!!
別の要件を満たしていない場合は申し訳ありません.. !!!