zoukankan      html  css  js  c++  java
  • EditText/RadioButton/CheckBox使用

    代码
    package com.test.android;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.*;
    import android.widget.CheckBox;
    import android.widget.CompoundButton;
    import android.widget.EditText;
    import android.widget.RadioGroup;
    import android.widget.Toast;

    public class HelloAndroid extends Activity {
        
    private EditText _editText;
        
    /** Called when the activity is first created. */
        @Override
        
    public void onCreate(Bundle savedInstanceState) {
            
    super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
            _editText 
    = (EditText)findViewById(R.id.EditText01);
            _editText.setHint(
    "请输入一个值");
            _editText.setOnKeyListener(
    new EditText.OnKeyListener(){
                
    public boolean onKey(View arg0, int arg1, KeyEvent arg2){
                    dispToast(
    "输入值:"+_editText.getText().toString());
                    
    return false;
                }
            });
            
            RadioGroup rgp 
    = (RadioGroup)findViewById(R.id.RadioGroup01);
            rgp.setOnCheckedChangeListener(
    new RadioGroup.OnCheckedChangeListener(){
                
    public void onCheckedChanged(RadioGroup group, int checkedId){
                    dispToast(Integer.toString(checkedId));
                }
            });
            
            CheckBox cb1 
    = (CheckBox)findViewById(R.id.CheckBox01);
            cb1.setOnCheckedChangeListener(
    new CheckBox.OnCheckedChangeListener(){
                
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked){
                    
    if (isChecked){
                        dispToast(
    "选择了"+buttonView.getText().toString());
                    }
                }
            });
        }
        
    public void dispToast(String str){
            Toast.makeText(
    this, str, Toast.LENGTH_SHORT).show();
        }
    }
  • 相关阅读:
    PDA固定资产条码管理系统软件-解决固定资产实物清查的瓶颈问题,大大提高清查效率
    互联网+下PDA移动智能手持POS超市收银开单软件
    搭建免费代理池
    解析库beautifulsoup
    爬取汽车之家新闻
    请求库之requests库
    网络状态码301与302
    正向代理与反向代理
    垃圾回收机制详解
    HTTP协议详解
  • 原文地址:https://www.cnblogs.com/wjhx/p/1679943.html
Copyright © 2011-2022 走看看