我在程序中动态的添加radiobutton,但是遇到个问题就是,当有很多歌radiobutton时,我想换行添加,也就是说限制每行的radiobutton个数。请问我该用什么方法换行呢!我的方法没有起到换行的作用。
我的代码如下: for(int n=1;n<9;n++)
{
RadioButton radioButton = new RadioButton(this);
radioButton.setWidth(80);
radioButton.setHeight(40);
radioButton.setText("孙悟空");
radioButton.setTextColor(Color.BLACK);
radioButton.setTextSize(14.0f);
if(n%3==0)
{
System.out.println("\n");
}
radiogroup.addView(radioButton);
}
我的代码如下: for(int n=1;n<9;n++)
{
RadioButton radioButton = new RadioButton(this);
radioButton.setWidth(80);
radioButton.setHeight(40);
radioButton.setText("孙悟空");
radioButton.setTextColor(Color.BLACK);
radioButton.setTextSize(14.0f);
if(n%3==0)
{
System.out.println("\n");
}
radiogroup.addView(radioButton);
}
解决方案 »
- 从Activity中开启Service的问题
- 是否可以不用安装apk,直接用真机仿真?
- 计算器里的删除键
- 不使用配置文件,代码如何创建包含一张图片和一个字符串的ListView?
- 【bugreport】android底下都有哪些bugreport开源项目啊
- 晒应用,赢大奖!高德“沿图有你 晒出你的LBS应用”开启
- 目前一个项目请大家给个思路
- Android 客户端与服务器的连接判断
- 关于如何在Android编程中调用Matlab的库函数
- android camera 多屏同时预览
- 程序执行着就出来下面的错误,是什么原因呢?
- 在activity里启动service之后怎么样才可以得到这个service的实例
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout androidrientation="horizontal"
android:layout_width="match_parent" android:layout_height="wrap_content">
<RadioButton android:text="01" android:id="@+id/radioButton1"
android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
<RadioButton android:text="02" android:id="@+id/radioButton2"
android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
</LinearLayout> <LinearLayout androidrientation="horizontal"
android:layout_width="match_parent" android:layout_height="wrap_content">
<RadioButton android:text="03" android:id="@+id/radioButton3"
android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
<RadioButton android:text="04" android:id="@+id/radioButton4"
android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
</LinearLayout>
</LinearLayout>只是思路 你看看吧。