I am getting error when i run this app on android :
Error :->>” Unfortunately exampleapp has stoped ”
Please help me .. When I remove the line :
logoImage.setOnClickListener(this);
no problm , its working fine .. I think I made some mistake with setOnClickListener() .
thank you !
package com.hightrax.mrgod;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
public class Main extends Activity implements OnClickListener
{
ImageView logoImage;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
logoImage = (ImageView) findViewById(R.drawable.logo);
logoImage.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
}
This:
…should probably be this:
…which also expects you to have an
<ImageView />in your layout XML with the id@+id/logo, similar to this:If your
ImageViewisn’t using the id@+id/logo, then just change theR.id.logoabove to whatever you’ve picked. 🙂TLDR: You’re trying to find a view based on the resource identifier of your
Drawable. This is not the same as the identifier you’ve given yourImageView.