Android(Kotlin)图片按钮,单选框,复选框(实验课)
Android的一次“实验课布置的内容”
里面有一些可以擦考的东西
所以借着CSDN来记个笔记
其实也没啥 第一次写 留个纪念
图片按钮,单选框,复选框(话不多说上代码)
button_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><ImageButtonandroid:layout_width="100dp"android:layout_height="100dp"android:id="@+id/iButton"android:background="@drawable/bg"/><CheckBoxandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/chinese"android:text="Chinese"/><CheckBoxandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/english"android:text="English"/><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/cButton"android:text="复选按钮确定"/><RadioGroupandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"
ButtonActivity.kt
package com.example.ui3import android.content.DialogInterface
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import kotlinx.android.synthetic.main.button_layout.*class ButtondoActivity : AppCompatActivity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.button_layout)iButton.setOnClickListener{var iTip:String = "图片"setTips(iTip)}cButton.setOnClickListener{var cTip:String = "复选"setTips(cTip)}rButton.setOnClickListener{val rTip:String = "单选"setTips(rTip)}}//根据按钮,设置输出内容fun setTips(tipString: String){var tips:String = getString(R.string.tips,tipString)tipSomething(tips)}//创建并显示对话框fun tipSomething(tipEnd: String){val builder = AlertDialog.Builder(this)builder.setMessage(tipEnd).setPositiveButton("确认",DialogInterface.OnClickListener { dialog, id ->// FIRE ZE MISSILES!})// Create the AlertDialog object and return itbuilder.create()builder.show()}
}
string.xml
<resources><string name="app_name">UI3</string><string name="tips">您点击了%1$s按钮!</string>
</resources>
这里插一段废话,string.xml写这些东西是为了简化代码,
实验报告的内容是根据点击不同按钮弹出内容不同的对话框,
因此在Activity读取string.xml内容(不提动态,磨磨唧唧的)
在占位符”%1$s”填写相应内动,来修改对话框所提示的内容,
注释还算详细。。。。。。
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.ui3"><applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"android:theme="@style/Theme.UI3"><activity android:name=".ButtondoActivity"><intent-filter><action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER"/></intent-filter></activity></application></manifest>
图片按钮的图片就不上传了,,,目录结构也都明白
效果图如下:
Android(Kotlin)图片按钮,单选框,复选框(实验课)相关推荐
- js 实现多选框(复选框) 和单选框,下拉框功能完整示例代码附效果图
<!DOCTYPE html> <html><head><meta charset="utf-8" /><script src ...
- 改变单选或者复选框的样式
原理是通过定位把以前的样式覆盖掉,就酱... 代码如下: css.checkbox{position: relative;padding-left: 8px;}.checkbox:before{con ...
- php一些单选、复选框的默认选择方法(示例)
转载 http://www.php.cn/php-weizijiaocheng-360029.html 一. radio和checkbox及php select默认选择的实现代码 1.radio单选框 ...
- Python3+Selenium3+webdriver学习笔记8(单选、复选框、弹窗处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记8(单选.复选框.弹窗处理)''' from selenium ...
- html5复选框控制按钮状态,HTML5如何添加原生radio按钮和checkbox复选框转换为非常好看的滑动开关按钮的插件...
本篇教程探讨了HTML5如何添加原生radio按钮和checkbox复选框转换为非常好看的滑动开关按钮的插件,希望阅读本篇文章以后大家有所收获,帮助大家HTML5+CSS3从入门到精通 . < ...
- jQuery 单选框/复选框美化
对于前端萌新来说,美化表单是个痛苦的事情,通常都是去寻找插件这种逃避的办法,其实这并不是难事.在上篇文章中提到了兄弟元素选择器在表单美化中表现突出,下面的示例源码将体现 基础篇知识的实际应用. 纯CS ...
- JQuery获取选中的元素(单选框复选框)及其他等
看注释 <!DOCTYPE html> <html><head><meta charset="utf-8"><title> ...
- html复选框美化插件,Labelauty – jQuery单选框/复选框美化插件
Labelauty – jQuery单选框/复选框美化插件 分类:代码 日期:2016-08-02 点击(38,744) 下载(0) 来源:未知 收藏 下拉框美化插件经常见到,如之前介绍过的 Drop ...
- html正方形单选框代码,单选框/复选框
[html]代码库 单选.复选框Demo function getSelectedEffect(effects) {//获取效果选项 for ( var i = 0; i < effects.l ...
- EasyUI:combotree(树形下拉框)复选框选中父节点(子节点的状态也全部选中)输入框中只显示父节点的文本值
在开发过程中遇到的小案例 效果展示 未处理之前的效果: 处理之后的效果: 需求详情 combotree(树形下拉框)复选框选中父节点时输入框只显示父节点的文本值,但是子节点的状态是选中的. 当所有子节 ...
最新文章
- Python:numpy库中的一些函数简介、使用方法之详细攻略
- python opencv如何读取本地视频并显示 cv2.VideoCapture()
- Intel和AMD的最新视频编码/解码基准测试
- Ubuntu 系统安装APACHE PHP MYSQL
- Atitit aop的一些资料 目录 2. AOP(面向切面)	1 2.1. 切面(Aspect):其实就是共有功能的实现。如日志切面、权限切面、事务切面等	2 2.2. 通知(Advice
- arcgis构建金字塔失败什么原因_新西兰创业移民转永居失败!原因是什么?
- 04 _ 可扩展架构案例(一):电商平台架构是如何演变的?
- Linux kernel 配置选项
- 优酷1080p的kux格式文件转换方法
- dingo php,laravel 使用dingo 和 jwt 【laravel7.3 dingo3.0 php7.3】配置
- Skywalking全链路追踪使用说明
- win7设置定时锁定计算机,Windows7电脑屏幕如何设置不自动锁屏
- python爬虫菜鸟教程-Python数据分析,学习路径拆解及资源推荐
- Java视频教程(浙江大学翁恺)
- Java引用包的方法
- 滴滴老年版来了,推出一键打车小程序,电话叫车服务
- 1683. Fridge
- 知识库 编号:010
- [附源码]java毕业设计校园二手交易平台的设计
- Mycat配置文件详解