i need to set a image dynamically before to text view on the below mentioned code , so how to do this.?my code is below..
if (attchStringArray.length > 0) {
LinearLayout attachemntLayout = new LinearLayout(mainContext);
LinearLayout.LayoutParams layoutParam = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
TextView attNameView = new TextView(mainContext);
ImageView Ivbackground= new ImageView(mainContext);
attNameView.setText(attchStringArray[2]);
attachemntLayout.addView(attNameView, layoutParam);
attachemntLayout.setBackgroundResource(R.drawable.bg_for_answers);
attachmentsection.addView(attachemntLayout);
}
I have added 2 lines in your original code. Check the lines that are preceded with comments.
EDIT: You should load the image view with some image using eg.
ImageView.setImageResource()orImageView.setImageDrawable()orImageView.setImageBitmap().