English 中文(简体)
简单布局问题
原标题:Simple Layout Issue
  • 时间:2012-05-25 21:01:24
  •  标签:
  • android

我面对一个在对话中制作文本浏览和搜索栏的问题。

我从android place

问题在于循环 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();
    }

}
最佳回答

您的 LayearLayout 默认为 方向=" 水平相向" 。 将其方向改为垂直, 您将会看到您想要的 。

LL.setOrientation(LinearLayout.VERTICAL);
问题回答

你的线性月球方向正确吗?

LL.setOrientation(LinearLayout.VERTICAL);




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签