开发者

How can i create image and link button from code (java) in android?

Android view is in xml file, and we can drag n drop controls to it, but now i want to create image and link buttons from a while loop in ja开发者_如何转开发va, it means we have to develop interface part from backend, how can we do so?


ImageButton inherits from ImageView and has its own properties compared to Button properties.

you can check properties here,
http://developer.android.com/reference/android/widget/ImageButton.html

Make your activity implement OnClickListener, then in OnCreate() or after that event. use ,

ImageButton btn = new ImageButton(this); or 
//ImageButton btn = (ImageButton) findViewById(R.id.imgbtnid)
btn.setOnClickListener(this);
in onClick() function you can handle the click event
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜