How to dynamically change the text radioButton location in the code?
I radioGroup generate a code number radioButton, as shown below: Now I want to change the display as shown below, it should be how to modify the code? Note: I am not in the XML definition radioGroup and radioButton, but dynamically added <-! Main posts under Banner (D4) -><-! Posts under the main text (D5) -> Reply: android: drawableBottom setCompoundDrawablesWithIntrinsicBounds (int, int, int, int) The drawable to be drawn below the text . Put your digital pictures with this attribute Try replaced Reply:
Thanks for reply, but these figures 6,7,8 and the like is to decide based on other dynamic content, no way to replace the picture. Reply: Drawable yourself with a selected state, then this radio button drawable set of drawableTop, then remove the system comes with a button Reply:
is to be set in code, not set in XMLI tried to do:
But there are still problems, as shown below: Reply: Just RadioButton code probably looked as if the button is not by setButtonDrawable set to null Try the button through xml set null
If you need to generate a RadioButton through the code, so you can
Reply: lz you want is not dynamically add code like this? RadioGroup rg = new RadioGroup (this); rg.setOrientation (RadioGroup.HORIZONTAL); String [] titles = new String [7]; titles [0] = "hot"; titles [1] = "investment"; titles [2] = "financing"; titles [3] = "cooperation"; titles [4] = "new"; titles [5] = "recruitment"; titles [6] = "job";
for (int i = 0; i { RadioBtnEx btn = new RadioBtnEx (this); btn.setTextSize (20); RadioGroup.LayoutParams btnParam = new RadioGroup.LayoutParams (LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); btnParam.leftMargin = 10; btnParam.topMargin = 2; btn.setText (titles [i]); rg.addView (btn, btnParam); } Reply:
No, the 4th floor figure that still exists excess blue dot Reply:
This is not, it is arranged laterally to achieve the various internal radiogroup radiobutton, but the result shown in Figure 1 can not make each radiobutton, the word is still on the right in the picture, and not shown in Figure 1 below. Reply:
Just RadioButton code probably looked as if the button is not by setButtonDrawable set to null Try the button through xml set null
If you need to generate a RadioButton through the code, so you can
No comments:
Post a Comment