按钮包含文字和放大器;从网上图片[机器人]
我怎么能得到一个图像并从互联网上的文本,并提出了按钮,我的动态Android应用程序?而在个位置,我想吸引他们。
在Java code即
how could i get an image and a text from the Internet and made a button for my android application dynamically?And draw them in th position i want. i.e by Java code
认为
下载图像和文本,则:
button.setText(downloadedText);
button.setBackgroundDrawable(drawable);
您需要创建从图像,你也许可以不使用的可绘制#createFromStream
。
You'll have to create a Drawable from the image, which you can probably do using Drawable#createFromStream
.
在绘制你想要的位置的按钮是一个普通按钮没有什么不同。刚刚宣布它在你的XML(可设置为Visibility.GONE在第一),用得到它的引用 View.findViewById
,然后做就可以了上述操作。
Drawing the button in the position you want is no different from a normal button. Just declare it in your XML (possible set to Visibility.GONE at first), get a reference to it using View.findViewById
and then do the above operations on it.