2014-09-19 52 views
0

我从ArrayList动态创建了一个RadioGroup,我已将其存储在一个对象中,但是当我将它添加到视图时,它出现在我上面的TextView的顶部。我能做些什么来阻止这种情况的发生?如何设置广播组的位置

我也根据对象中的另一个字段设置TextView

感谢任何人看着这个!

  text.setText(list.get(counter).getText().toString()); 
      image.setImageBitmap(result); 
      a = list.get(counter).getA(); 

      for(int i = 0; i < a.size(); i++){ 

       RadioButton btn = new RadioButton(MainActivity.this); 
       btn.setId(i); 
       btn.setText(a.get(i)); 
       btn.setChecked(false); 

       radioGroup.addView(btn); 
      } 

回答

0

好的。我想到了。我能够通过设置一些LayoutParams然后通过使用addRule()

layout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
    layout.addRule(RelativeLayout.BELOW, text.getId()); 
    radiogroup.setLayoutParams(layout);