解决方案 »

  1.   

    就是不知道应该怎么用代码生成,试过再建一个layout但是没用啊,再养把他们都放在一个layout里 并且这里面有纵向排列也有横向排列的控件呢?谢谢各位大神们了~~~
      

  2.   

    layout里面嵌套layout不就行了么,,,,
      

  3.   

    这是基础吧<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >    <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" />    <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" />    <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" />    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >        <Button
                android:id="@+id/button4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />        <Button
                android:id="@+id/button5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />        <Button
                android:id="@+id/button6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />    </LinearLayout></LinearLayout>
      

  4.   

    还有就是我上面的那个latout如果做一个循环的话 那么新的layout就会覆盖之前的布局了,怎么让它们循环并且以此向下继续生成,不覆盖原有的布局
      

  5.   

    大哥 我是想用纯代码在java类里生成~ 不带用xml的
      

  6.   

    解释一下,由于内容是从网上传递过来的json,而且格式也不固定,可能这道题里2个选项,下一个就3个了,所以准备在类里用代码纯生成布局,就不r.layout.(xml)了,现在问题是怎么让我的一个 LinearLayout里又有纵向又有横向,如果添加俩个 LinearLayout 的话,新的 LinearLayout 会覆盖原来的 LinearLayout ,所以这里就有俩个问题想向大家请教,1,如何让一个Layout 存在纵向和横向的俩种布局 2,如何在循环上面的 LinearLayout 的时候让第二个生成在第一个layout的下面。 求大神解答啊~
      

  7.   

    额,那你就写两个layout,指定指定高、宽、权重,两个layout凑成一个屏幕,LinearLayout.LayoutParams  params=new LinearLayout.LayoutParam(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,weight)
      

  8.   

    还是不行啊
    ScrollView svScrollView = new ScrollView(this);//////////////////////////////////////滚动条
    LinearLayout lLayout = new LinearLayout(this);
    LinearLayout lLayout2 = new LinearLayout(this);
    lLayout.setOrientation(LinearLayout.VERTICAL);
    lLayout2.setOrientation(LinearLayout.HORIZONTAL);
    TextView TV1 = new TextView(this);
    RadioGroup RDgroup = new RadioGroup(this);//实例化单选按钮组
    TextView TV2 = new TextView(this);
    final TextView TV3 = new TextView(this);
    TV1.setText("第一道题");
    TV2.setText("你选的是:");
    TV3.setText("123");
    lLayout.addView(TV1);
    for(int i = 0 ; i < 5 ; i++){
             RadioButton radio = new RadioButton(this);
             radio.setText("radio" + i);
             RDgroup.addView(radio);
            }
    lLayout.addView(RDgroup);
    lLayout2.addView(TV2);
    lLayout2.addView(TV3);
    svScrollView.addView(lLayout2);
    svScrollView.addView(lLayout);
    setContentView(svScrollView);
    我是在上面多加了个滚动条的容器,然后里面建俩个layout都放进去运行就告诉我不能运行,但是单个的layout添加都是可以的,应该怎么放到一起啊 
      

  9.   

    不行啊 设置之后每个
    LinearLayout.LayoutParams lp= new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,200);
    lLayout2.addView(TV3,lp);
    都加了高度还是不成啊
      

  10.   

    不行啊 设置之后每个
    LinearLayout.LayoutParams lp= new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,200);
    lLayout2.addView(TV3,lp);
    都加了高度还是不成啊额,我下载过的demo,它就是设置了两个高度以后就可以叠加使用了,你等我找找那个demo
      

  11.   

    不行啊 设置之后每个
    LinearLayout.LayoutParams lp= new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,200);
    lLayout2.addView(TV3,lp);
    都加了高度还是不成啊额,我下载过的demo,它就是设置了两个高度以后就可以叠加使用了,你等我找找那个demo哦 好谢谢哈