is it possible to use a url
to set background
for framelayout
?
Example:
i want to use the URL like this as my framelayou
Something interested, (I never try this but it should work)
FrameLayout fm = (FrameLayout)findViewById(R.id.FrameLayout01);
Drawable drw = ImageOperations(this,url,filename)
fm.setBackgroundDrawable(drw)
Convert your image url in Drawable using
private Drawable ImageOperations(Context ctx, String url, String saveFilename) {
try {
InputStream is = (InputStream) this.fetch(url);
Drawable d = Drawable.createFromStream(is, saveFilename);
return d;
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public Object fetch(String address) throws MalformedURLException,IOException {
URL url = new URL(address);
Object content = url.getContent();
return content;
}
Try this and let me know what happen..