So I\'m new to android development...How can I create an image that acts like button, so when I press that image, image starts a specific activity. So I want this to show as ima
With the ImageView element, attaching a click listener to it.
The XML:
The code:
ImageView imageView = (ImageView) findViewById(R.id.myImageView);
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ThisActivity.this, MyOtherActivity.class);
startActivity(intent);
}
});
You also could use a ImageButton (in the same way). It makes almost no difference. You can see more details here. Difference between a clickable ImageView and ImageButton