Hello, I created a relative layout by code in java wich basically is a list on wich each row has 3 elements.. name, age and sex but then i want that age be displayed below name and the image of the gender be displayed on the right of the screen (not imediatly right of the name). the problem is that when I coded that, it just overlaps everything and I got no idea what I'm doing wrong =S any ideas? here is the code:
public class PersonasAdapterView extends RelativeLayout { private final static int idNombreView = 0; private static final int idEdadView = 1; private static final int idImgView =2; private TextView viewNombre; private TextView viewAge; private ImageView sexImg; public PersonasAdapterView(Context context, Personas per) { super(context); //layout for name in textview RelativeLayout.LayoutParams nameParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); nameParams.setMargins(10, 1, 1, 1); TextView viewNombre = new TextView(context); viewNombre.setText(per.getName()); viewNombre.setId(idNombreView); viewNombre.setTextSize(19f); viewNombre.setTextColor(Color.BLACK); addView(viewNombre,nameParams); //layout for age in textview RelativeLayout.LayoutParams ageParams= new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); ageParams.setMargins(1, 1, 1, 1); ageParams.addRule(RelativeLayout.BELOW,viewNombre.getId()); TextView viewEdad = new TextView(context); viewEdad.setText(String.valueOf(per.getAge())); viewEdad.setId(idEdadView); viewEdad.setTextSize(14f); viewEdad.setTextColor(Color.BLACK); addView(viewEdad,ageParams); //layout for img RelativeLayout.LayoutParams imParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); imParams.addRule(CENTER_VERTICAL,ALIGN_PARENT_RIGHT); ImageView imSex = new ImageView(context); imSex.setImageResource(per.getSexImg()); imSex.setId(idImgView); addView(imSex,imParams); } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en