我面对一个在对话中制作文本浏览和搜索栏的问题。
问题在于循环 TextView & amp; 搜索栏应该添加5次, 并应在对话框中显示。 但只显示一个文本View 。
这是代码:
public void onCheckedChanged(RadioGroup rgroup, int rbutton) {
String eqSettingName = ((RadioButton) findViewById(rbutton)).getText()
.toString();
if (eqSettingName.equals("Custom")) {
Dialog dialog = new Dialog(this);
dialog.setTitle("Custom Equalizer");
LinearLayout LL = new LinearLayout(this);
short noOfBands = mEqualizer.getNumberOfBands();
final short minEQLevel = mEqualizer.getBandLevelRange()[0];
final short maxEQLevel = mEqualizer.getBandLevelRange()[1];
for (short i = 0; i < noOfBands; i++) {
short band = i;
TextView freqTV = new TextView(this);
freqTV.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
freqTV.setGravity(Gravity.CENTER_HORIZONTAL);
freqTV.setText((mEqualizer.getCenterFreq(band)) / 1000 + " Hz");
LL.addView(freqTV);
SeekBar bar = new SeekBar(this);
bar.setLayoutParams(layoutParams);
bar.setMax(maxEQLevel - minEQLevel);
bar.setProgress(mEqualizer.getBandLevel(band));
LL.addView(bar);
}
/*
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.customseekbar,
(ViewGroup) findViewById(R.id.rlCustomEqualizerSeekBar));
*/
dialog.addContentView(LL, layoutParams);
dialog.show();
}
}