package com.example.maxview;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
public class MainActivity extends Activity {
int []images=new int[]{
R.drawable.java,
R.drawable.javaee,
R.drawable.swift,
R.drawable.ajax,
R.drawable.html,
};
int currentImg=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout main=(LinearLayout) findViewById(R.id.root);
final ImageView imageView=new ImageView(this);
main.addView(imageView);
imageView.setImageResource(images[0]);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
imageView.setImageResource(images[++currentImg%images.length]);
}
});
}
}
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
public class MainActivity extends Activity {
int []images=new int[]{
R.drawable.java,
R.drawable.javaee,
R.drawable.swift,
R.drawable.ajax,
R.drawable.html,
};
int currentImg=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout main=(LinearLayout) findViewById(R.id.root);
final ImageView imageView=new ImageView(this);
main.addView(imageView);
imageView.setImageResource(images[0]);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
imageView.setImageResource(images[++currentImg%images.length]);
}
});
}
}