Question

I have a function

 public void creacion_layout_items(R.drawable imagen_principal){
  LinearLayout _33_1_layout=(LinearLayout)findViewById(R.id.layout_principal);                               
        ImageView imagen=new ImageView(this);   
        LinearLayout.LayoutParams imagen_Params = new LinearLayout.LayoutParams(12,12);
        imagen.setLayoutParams(imagen_Params);
        imagen.setBackgroundResource(imagen_principal);
_33_1_layout.addView(imagen);
}

and I want to call the function

creacion_layout_items(R.drawable.all);

but does not work

Was it helpful?

Solution

R.drawable.something is of int type. R.drawable is not type at all. So use

public void creacion_layout_items(int yourResDrawableId){
   ...
 imagen.setBackgroundResource(yourResDrawableId);
   ...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top