Monday, February 17, 2014

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:
cited a floor shen332401890 reply:
android: drawableBottom setCompoundDrawablesWithIntrinsicBounds (int, int, int, int) The drawable to be drawn below the text

Put your digital pictures replaced with this attribute try

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:
reference to the third floor youngc527 reply:
own drawable with a selected state, then this radio button drawable set of drawableTop, then remove the system comes The button

is to be set in code, not set
in XMLI tried to do:
 
rb.setButtonDrawable (null);
rb.setCompoundDrawablesWithIntrinsicBounds (0, android.R.drawable.btn_radio, 0, 0);

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

1 Definition XML

android: button = "@ null"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content" />

2 Create RadioButton
RadioButton newButton = (RadioButton) LayoutInflater.from (this) inflate (R.layout.radio_without_button, parent, false);.

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:
references, 5th Floor youngc527 reply:
RadioButton's just probably looked at the code, it seems that by setButtonDrawable can not be set to null
buttonTry the button through xml set null

If you need to generate a RadioButton through the code, so you can

1 Definition XML

android: button = "@ null"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content" />

2 Create RadioButton
RadioButton newButton = (RadioButton) LayoutInflater.from (this) inflate (R.layout.radio_without_button, parent, false);.

No, the 4th floor figure that still exists excess blue dot
Reply:
reference to the 6th floor inzaghi97 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);
}

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:
reference to the 7th floor qianru08 reply:
Quote: references, 5th Floor youngc527 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

1 Definition XML

android: button = "@ null"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content" />

2 Create RadioButton
RadioButton newButton = (RadioButton) LayoutInflater.from (this) inflate (R.layout.radio_without_button, parent, false);.

No, the 4th floor figure that extra blue dot remains


reference to the 7th floor qianru08 reply:
Quote: references, 5th Floor youngc527 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

1 Definition XML

android: button = "@ null"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content" />

2 Create RadioButton
RadioButton newButton = (RadioButton) LayoutInflater.from (this) inflate (R.layout.radio_without_button, parent, false);.

does not work, that there are still excess blue dot

4 F chartI made a mistake, 4th floor approach is possible, the function has been achieved.
Reply:
Find examples. . .

No comments:

Post a Comment