开发者

How to insert both an image and a button in an Android application at once?

I need to insert two images and two buttons. The action required is that when I click on the first button, the corresponding image 开发者_开发问答should be displayed. The same action is required for other button also, but the second image should be displayed.


I'm guessing you mean a button with an image on it?

For that, you'll need an ImageButton.


Image button can be added as

<ImageButton android:layout_width="wrap_content" android:id="@+id/ImageButton01" android:layout_height="wrap_content" android:src="@drawable/icon">
</ImageButton>


Assuming we finally understood what is required you need to have an onClick listener on both the buttons which when invoked will change the image you are displaying :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜