android - Unable to set LinearLayout BackgroundResource from URL using Picasso -


i have linearlayout i'd change background of programatically:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/downloadlayout"     android:layout_width="match_parent"     android:layout_height="wrap_content"      android:weightsum="1" >     ... 

and i've attempted set background image of xml layout using following:

linearlayout linearlayout2 = (linearlayout) findviewbyid(r.id.downloadlayout);         int resid = getresources().getidentifier(background,                 "drawable", getpackagename()); 

linearlayout2.setbackgroundresource(resid);

however background image never loads, there no npe, image never loads. suggestions appreciated.

i've done bit of debugging , have following values:

        linearlayout2 = android.widget.linearlayout{529b3f58 v.e..... ......i. 0,0-0,0 #7f0a008e app:id/downloadlayout}         background = http://xxx.xxx.x.xxx/bgs/big_lebowski_bg.jpg         resid = 0 

p.s.

i've tried accomplishing same using picasso - i'm not sure how around error stated , load successfully:

source:

final linearlayout downloadlayout = (linearlayout) findviewbyid(r.id.downloadlayout); picasso.with(this).load("http://i.imgur.com/dvpvklr.png").into(downloadlayout); 

error:

the method into(target) in type requestcreator not applicable arguments (linearlayout) 

picasso works imageviews only, not layouts.

you put imageview inside layout, set match parent's width , height, , inject image imageview.

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"         android:id="@+id/downloadlayout"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:weightsum="1" >         <imageview             android:id="@+id/imageview"             android:layout_width="match_parent"             android:layout_height="match_parent" /> </linearlayout> 

this should work then:

imageview imageview = (imageview) findviewbyid(r.id.imageview);     picasso.with(this).load("http://i.imgur.com/dvpvklr.png").into(imageview); 

Comments