如何在textview中显示均衡器带的值?

时间:2018-12-09 20:22:25

标签: java android for-loop android-seekbar equalizer

我的问题是我想在均衡器对象中每个波段的每个搜索栏中显示一个textview。

textview确实显示在搜索栏中,但是当我移动搜索栏时,只有最下面的一个显示。

知道为什么吗?

enter image description here

Equalizer.java代码

private void setupEqualizer(){

    short numberOfBandsFreq = mEqualizer.getNumberOfBands();

    final short lowerEqualizerBandLevel = mEqualizer.getBandLevelRange()[0];
    final short upperEqualizerBandLevel = mEqualizer.getBandLevelRange()[1];

    for (short i = 1; i < numberOfBandsFreq; i++){
        final short equalizerBandIndex = i;

        mEqLinearLayout.setGravity(Gravity.CENTER);


       final ArcSeekBar arcSeekBar = new ArcSeekBar(this);


       progressValueTv = new TextView(this);
       progressValueTv.setLayoutParams(paramsProgress);
       progressValueTv.setTextColor(getResources().getColor(R.color.white));
       progressValueTv.setText("0dB");

        int[] colorArray = getResources().getIntArray(R.array.gradient);

        arcSeekBar.setId(i);
        arcSeekBar.setLayoutParams(arkSeekBarParams);
        arcSeekBar.setProgressWidth(50);
        arcSeekBar.setProgressGradient(colorArray);
        arcSeekBar.setMaxProgress(upperEqualizerBandLevel - lowerEqualizerBandLevel);
        arcSeekBar.setProgress(mEqualizer.getBandLevel(equalizerBandIndex));

        arcSeekBar.setOnProgressChangedListener(new ProgressListener() {
            @Override
            public void invoke(int i) {
                mEqualizer.setBandLevel(equalizerBandIndex, (short) (i + lowerEqualizerBandLevel ));
                progressValueTv.setText(String.valueOf((i + lowerEqualizerBandLevel) / 100) + " dB");
            }
        });

        seekBarRowLayout.addView(lowerEqualizerBandLevelTv);
        seekBarRowLayout.addView(arcSeekBar);
        seekBarRowLayout.addView(progressValueTv);
        seekBarRowLayout.addView(upperEqualizerBandLevelTv);

        mEqLinearLayout.addView(seekBarRowLayout);

    }

}

0 个答案:

没有答案