1

At first ... I had a Imageview in my XML file layout but then I changed my opinion and delete the Imageview and put an ImageButton in it.

So far so good

The Problem occurs that the onclick method of the ImageView doesn't work with the ImageButton :(

But I don't know why

Here ist my XML Piece of the ImageButton

<

ImageButton
android:id="@+id/LPic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:src="@drawable/t189"
android:onClick="onButtonClick"  *** 

I marked the line with three stars - if I delete the line - the app worked - but no click Action anyway

If I put it back - eclipse says nullpointerexeption couldn't not execute method of the activity - onclick

My onbuttonclick method stays the same as with the Imageview

public void onButtonClick (View view){
bla bla bla ..}

Inside I changed the pic of the ImageButton with

ImageButton LPic = (ImageButton)findViewById(R.id.LPic);

    String Path = SavePath.toString()+"/"+PicFiles[ZL];
        Drawable d = Drawable.createFromPath(Path);
        LPic.setImageDrawable(d);
Chad White
  • 309
  • 1
  • 4
  • 15
  • I'm not sure but in this [question](http://stackoverflow.com/questions/4153517/how-exactly-does-the-androidonclick-xml-attribute-differ-from-setonclicklistene) they are using an other method signature. So may that is the problem. Try to change your onButtonClick Mehtod to `onButtonClick(View v)` – ZeusNet Aug 09 '13 at 12:13
  • No thats not the point - same error as ever – Chad White Aug 09 '13 at 12:51
  • It works anyway - why I don't know - error solved - but the button didn't Show how I think it should - I think its's a layout thing – Chad White Aug 09 '13 at 15:45

0 Answers0