0

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

thinks

ilredelweb
  • 3,091
  • 4
  • 17
  • 14
  • 1) http://developer.android.com/reference/android/widget/ImageButton.html 2) http://stackoverflow.com/questions/2909280/android-image-fetching – ankitjaininfo Sep 30 '10 at 08:38

1 Answers1

1

Download the image and the text, then:

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

You'll have to create a Drawable from the image, which you can probably do using Drawable#createFromStream.

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.

benvd
  • 5,776
  • 5
  • 39
  • 59