Chinaunix首页 | 论坛 | 博客
  • 博客访问: 327385
  • 博文数量: 96
  • 博客积分: 2041
  • 博客等级: 大尉
  • 技术积分: 1080
  • 用 户 组: 普通用户
  • 注册时间: 2012-01-20 14:08
文章分类

全部博文(96)

文章存档

2015年(2)

2013年(1)

2012年(93)

分类: 系统运维

2012-02-06 15:33:22

java.lang.Object
   android.view.View
     android.widget.TextView
       android.widget.Button
         android.widget.CompoundButton
           android.widget.CheckBox

 

复选框也是一个Button

      android:id="@+id/url1"
      android:text=""
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"/>
      android:id="@+id/url2"
      android:text="bbs.ebxiao.com"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"/>
      android:id="@+id/url3"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"/>

Activity:

package your.pacfkage.namespace;

import android.app.Activity;
import android.os.Bundle;
import android.widget.CheckBox;

public class CheckBoxActivity extends Activity
{
    private CheckBox box = null ;
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        this.box = (CheckBox)super.findViewById(R.id.url3) ;//取得组件
        this.box.setChecked(true) ;//将此组件设置为默认选中
        this.box.setText("ebxiao.com") ;//设置显示文字
    }
}

阅读(750) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~