2010-09-30 47 views
0

我怎樣才能從互聯網上獲取圖像和文本,並動態地爲我的android應用程序製作按鈕?並將它們繪製在我想要的位置。 即通過Java代碼按鈕包含來自互聯網的文本和圖像[android]

認爲

+0

1)http://developer.android.com/reference/android/widget/ImageButton.html 2)http://stackoverflow.com/questions/2909280/android-image-fetching – ankitjaininfo 2010-09-30 08:38:11

回答

1

下載圖像和文本,然後:

button.setText(downloadedText); 
button.setBackgroundDrawable(drawable); 

你必須創建圖像,你可以做很可能使用Drawable#createFromStream可繪製。

在所需位置繪製按鈕與普通按鈕沒有區別。只需在您的XML中聲明它(可能首先設置爲Visibility.GONE),使用View.findViewById獲取對它的引用,然後對其執行上述操作。

+0

想你。這非常有幫助 – ilredelweb 2010-09-30 09:06:44