Reputation: 21
I keep getting this error message and I am not sure what I am supposed to do.
The method setOnClickListener(new View.OnClickListener(){})
is undefined for the type imageButton1
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imageButton1 imagebutton1 = (imageButton1) findViewById(R.id.imageButton1);
imageButton1.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
ImageView iv = (ImageView) findViewById(R.id.imageview1);
iv.setVisibility(View.VISIBLE);
}
});
Upvotes: 1
Views: 6749
Reputation: 91663
Try:
ImageButton imageButton1 = (ImageButton) findViewById(R.id.imageButton1);
imageButton1.setOnClickListener ....
ImageButton is the name of the class, imageButton1 the name of your instance of the class.
Upvotes: 5