开发学院手机开发Android 开发 Android控件(View)之TextView, Button, ImageButt... 阅读

Android控件(View)之TextView, Button, ImageButton, ImageView, CheckBox

 2010-09-27 02:07:00 来源:WEB开发网   
核心提示:android:checkedButton="@+id/rad3" android:orientation="horizontal"android:gravity="center_vertical|center_horizontal">< Radi

android:checkedButton="@+id/rad3" android:orientation="horizontal"

android:gravity="center_vertical|center_horizontal">

< RadioButton android:text="rad1" android:id="@+id/rad1"

android:layout_width="wrap_content" android:layout_height="wrap_content">< /RadioButton>

< RadioButton android:text="rad2" android:id="@+id/rad2"

android:layout_width="wrap_content" android:layout_height="wrap_content">< /RadioButton>

< RadioButton android:text="rad3" android:id="@+id/rad3"

android:layout_width="wrap_content" android:layout_height="wrap_content">< /RadioButton>

< /RadioGroup>

< /LinearLayout>

_RadioButton.java

代码

package com.webabcd.view;

import android.app.Activity;

import android.os.Bundle;

import android.widget.RadioButton;

import android.widget.RadioGroup;

import android.widget.TextView;

public class _RadioButton extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

this.setContentView(R.layout.radiobutton);

setTitle("RadioButton");

RadioGroup group = (RadioGroup) this.findViewById(R.id.radioGroup);

// setOnCheckedChangeListener() - 响应单选框组内的选中项发生变化时的事件

group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

@Override

public void onCheckedChanged(RadioGroup group, int checkedId) {

TextView txt = (TextView) _RadioButton.this.findViewById(R.id.textView);

txt.setText(((RadioButton)findViewById(checkedId)).getText() + " 被选中");

}

});

}

}

7、AnalogClock 的 Demo

上一页  1 2 3 4 5 6 7 8  下一页

Tags:Android 控件 View

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接