checkbox 方法运用
来源:互联网 发布:斗鱼手机客户端无网络 编辑:程序博客网 时间:2024/05/17 07:16
xml 文件
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.administrator.xuexi.MainActivity"> <CheckBox android:checked="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="足球" android:id="@+id/checkBox" android:layout_alignParentTop="true" android:layout_alignParentStart="true" /></RelativeLayout>
java
package com.example.administrator.xuexi;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.util.Log;import android.widget.CheckBox;import android.widget.CompoundButton;import android.widget.Toast;public class MainActivity extends AppCompatActivity { private CheckBox checkBox; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); checkBox =(CheckBox)findViewById(R.id.checkBox); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { //通过OnCheckedChanged来监听当前的checkBox是否被选中 if (b){ //获得checkbox的文本内容 String text = checkBox.getText().toString(); Toast toast=Toast.makeText(MainActivity.this,text,Toast.LENGTH_SHORT); toast.show(); } } }); }}
0 0
- checkbox 方法运用
- android CheckBox的运用
- android CheckBox的运用
- jq CheckBox运用
- jquery中checkbox运用
- Flex4.5CheckBox复选框组件运用
- js在datatables中运用checkbox
- 多项选择~checkbox的简单运用
- [DevExpress]TreeListLookUpEdit带checkbox之经典运用
- checkbox全选JS方法
- checkbox全选方法
- jquery checkbox 选中方法
- android:CheckBox方法
- jquery checkbox常用方法
- checkbox实现方法 (备忘)
- ArrayList运用方法
- 运用postgres常用方法
- Java Applet运用方法
- Android Studio 模板用法与自定义模板
- 【Java基础】Java中多态的理解
- NYOJ-17-单调递增最长子序列
- 擅长排列的小明
- 发送有序广播
- checkbox 方法运用
- Windows下Git多账号配置,同一电脑多个ssh-key的管理
- mysql 常用操作
- PHP中的ob_start用法详解
- leetcode 347. Top K Frequent Elements 将Hashmap统计次数的Entry,放到List<Entry>里面,对list排序后出现结果
- (HDU 5794)2016 Multi-University Training Contest 6 A Simple Chess (Lucas、容斥)
- mono for android 各版本下载地址
- 常见化学物质
- 【python】第一天——“hello world”及基本语法