I am trying to create an equalizer for RadioGroup. And I want to dynamically add a switch for presets.
Here is my XML layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RadioGroup
android:id="@+id/rgEqualizerPreset"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</RadioGroup>
</LinearLayout>
And here is the Java code:
RadioGroup rgEqualizer;
List<RadioButton> radioButtonList;
MediaPlayer mPlayer;
Equalizer mEqualizer;
LinearLayout.LayoutParams layoutParams;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.equalizer);
rgEqualizer = (RadioGroup) findViewById(R.id.rgEqualizerPreset);
mPlayer = new MediaPlayer();
mEqualizer = new Equalizer(0, mPlayer.getAudioSessionId());
rgEqualizer = new RadioGroup(this);
radioButtonList = new ArrayList<RadioButton>();
fillRadioGroupWithRadioButtons();
rgEqualizer.setOnCheckedChangeListener(this);
}
private void fillRadioGroupWithRadioButtons() {
Short noPresets = mEqualizer.getNumberOfPresets();
int i = 0;
while (i < noPresets) {
RadioButton rb = new RadioButton(this);
rb.setText(mEqualizer.getPresetName((short) i));
layoutParams = new RadioGroup.LayoutParams(
RadioGroup.LayoutParams.FILL_PARENT,
RadioGroup.LayoutParams.FILL_PARENT);
rgEqualizer.addView(rb, layoutParams);
i++;
}
}
@Override
public void onCheckedChanged(RadioGroup arg0, int arg1) {
}
When this action is opened, only a blank layout screen is displayed. What am I missing?
thank
source
share