Android中的各种button
来源:互联网 发布:淘宝哪家mcm高仿比较好 编辑:程序博客网 时间:2024/04/30 23:42
一、Button
包含点击、长按、移动、焦点、键盘事件
二、Imagebutton
1,src属性储存图片位置
2,根据图片大小决定button按钮的大小
三、Togglebutton
textOn和textOff
点击button会在两个信息之间进行切换
四、Radiobutton(单选按钮)
通常一个ButtonGroup中含有多个Radiobutton
1,布局文件
<RadioGroup android:layout_width="202dp" android:layout_height="326dp" tools:layout_constraintTop_creator="1" android:layout_marginStart="59dp" android:layout_marginTop="52dp" tools:layout_constraintLeft_creator="1" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" android:layout_marginLeft="59dp"> <RadioButton android:id="@+id/radioButton4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="RadioButton" /> <RadioButton android:id="@+id/radioButton5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="RadioButton" /> <RadioButton android:id="@+id/radioButton6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="RadioButton" /> </RadioGroup>
可以添加tag,用于储存各按钮的实际信息
text实际上只是一个展示信息
2,Java代码
可以通过监听获取所选的按钮
package com.example.administrator.radiobutton;import android.support.annotation.IdRes;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.widget.RadioButton;import android.widget.RadioGroup;public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RadioGroup radioGroup = (RadioGroup) findViewById(R.id.Radiogroup); radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) { RadioButton radioButton=(RadioButton) group.findViewById(checkedId); } }); }}
五、CheckBox(多选按钮)
1,布局文件
<CheckBox android:id="@+id/checkBox2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="CheckBox" tools:layout_editor_absoluteY="99dp" tools:layout_editor_absoluteX="101dp" /> <CheckBox android:id="@+id/checkBox3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="CheckBox" tools:layout_editor_absoluteY="178dp" tools:layout_editor_absoluteX="101dp" />
监听事件如RadioButton
阅读全文
0 0
- Android中的各种button
- Android中的Button控件
- Android中的Button
- Android中的Button按钮
- Android中的Button注册监听
- Android中listview中的button
- android中的button动画效果
- Android中的各种布局
- Android中的各种布局
- android中的各种尺寸
- Android中的各种Adapter
- Android中的各种布局
- Android中的各种Adapter
- Android中的各种布局
- Android中的各种布局
- Android中的各种布局
- Android中的各种loading
- Android中的各种Manager
- Genius Vision NVR (2) Install
- java TCP/IP Socket编程-----NIO--TCP信道-----笔记11
- Linux 信号(三)sigaction函数
- svn工具——菜单项功能备注
- Android 四种布局方式详解
- Android中的各种button
- 实现用户注册与登录、登出(三)
- java读取配置文件的方法
- iOS开发 防止button快速点击
- ELK日志分析系统搭建
- 套接字与FIFO
- Linux--搭建postfix邮件服务器
- JProfiler入门教程-简单的java程序性能调优
- 在Linux系统Centos6.9安装locate命令