如何添加Runtime ImageViews到linearlayout



我得到运行时imageviews,我怎么能把imageviews添加到一个单一的线性布局。

LinearLayout linearLayout=new LinearLayout(this);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    LinearLayout.LayoutParams vp=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
    ImageView imageView= new ImageView(this);
    imageView.setImageBitmap(bitMap);
    imageView.setVisibility(View.VISIBLE);
    imageView.setBackgroundColor(0xFFFF00FF);
    //linearLayout=LinearLayout+imageView;
    LinearLayout.LayoutParams Iv=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
    linearLayout.setLayoutParams(Iv);
    linearLayout.addView(imageView);
    setContentView(linearLayout,vp);
LinearLayout linearLayout=new LinearLayout(this);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams vp=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
ImageView imSex = new ImageView(context);
addView(imSex,linearLayout);

最新更新