按钮包含文字和放大器;从网上图片[机器人] [英] Button contains text & image from the Internet [android]

查看:88
本文介绍了按钮包含文字和放大器;从网上图片[机器人]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能得到一个图像并从互联网上的文本,并提出了按钮,我的动态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.

这篇关于按钮包含文字和放大器;从网上图片[机器人]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆