起初......我的XML文件布局中有一个Imageview,但随后 我改变了我的观点并删除了Imageview并在其中放入了ImageButton。
到目前为止一切顺利
出现问题,ImageView的onclick方法不起作用 使用ImageButton :(
但我不知道为什么
这是我的ImageButton的XML片段
<
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" ***
我用三颗星标记了这条线 - 如果我删除该线 - 该应用程序工作 - 但无论如何都没有点击动作
如果我把它放回去 - eclipse说nullpointerexeption 无法执行活动的方法 - onclick
我的onbuttonclick方法与Imageview
保持一致public void onButtonClick (View view){
bla bla bla ..}
我在里面用
更改了ImageButton的图片ImageButton LPic =(ImageButton)findViewById(R.id.LPic);
String Path = SavePath.toString()+"/"+PicFiles[ZL];
Drawable d = Drawable.createFromPath(Path);
LPic.setImageDrawable(d);