当前位置: 首页 > news >正文

哈尔滨市建设工程交易中心网站电话销售企业网站怎么做

哈尔滨市建设工程交易中心网站,电话销售企业网站怎么做,网站开发的好处和弊端,中山网站制作方案点击事件和长按事件 监听器#xff1a;专门监听控件的动作行为。只有控件发生了指定的动作#xff0c;监听器才会触发开关区执行对应的代码逻辑。按钮控件有两种常用的监听器#xff1a; 点击监听器#xff1a;通过setOnClickListener方法设置。按钮被按住少于500ms时会触…点击事件和长按事件 监听器专门监听控件的动作行为。只有控件发生了指定的动作监听器才会触发开关区执行对应的代码逻辑。按钮控件有两种常用的监听器 点击监听器通过setOnClickListener方法设置。按钮被按住少于500ms时会触发点击事件。长按监听器通过setOnLongClickListener方法设置。按钮被按住超过500ms时会触发长按事件。 点击事件 只有一个按钮 示例代码 package com.example.chapter03import android.annotation.SuppressLint import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.View import android.widget.Button import android.widget.TextView import com.example.chapter03.util.DateUtilclass ButtonClickActivity : AppCompatActivity() {SuppressLint(MissingInflatedId)override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_button_click)val tv_result: TextView findViewById(R.id.tv_result)val btn_click_single: Button findViewById(R.id.btn_click_single)btn_click_single.setOnClickListener(MyOnClickListener(tv_result)) // 实例化类的一个对象出来}// 创建一个类 MyOnClickListener 来实现 View.OnClickListener 接口class MyOnClickListener(private val tv_result: TextView) : View.OnClickListener {override fun onClick(p0: View?) {val dsec String.format(%s 您点击了按钮 %s, DateUtil.getNowTime(), (p0 as Button).text)tv_result.text dsec // kotlin不用set()也不用get()}} }?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalButtonandroid:idid/btn_click_singleandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:text指定单独的点击监听器android:textColor#000000android:textSize15sp/TextViewandroid:idid/tv_resultandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:padding5dpandroid:gravitycenterandroid:textColor#000000android:textSize15spandroid:text查看按钮点击的结果/ /LinearLayout运行结果 穿插kotlin小笔记 构造器传参 简写 class MyOnClickListener: View.OnClickListener {private val tv_result: TextViewconstructor(tv_result: TextView) {this.tv_result tv_result} }// 改进 class MyOnClickListener(private val tv_result: TextView) : View.OnClickListener {}有两个按钮 示例代码 package com.example.chapter03import android.annotation.SuppressLint import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.View import android.widget.Button import android.widget.TextView import com.example.chapter03.util.DateUtilclass ButtonClickActivity : AppCompatActivity() {SuppressLint(MissingInflatedId)override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_button_click)val tv_result: TextView findViewById(R.id.tv_result)val btn_click_single: Button findViewById(R.id.btn_click_single)btn_click_single.setOnClickListener(MyOnClickListener(tv_result)) // 实例化类的一个对象出来val btn_click_public: Button findViewById(R.id.btn_click_public)btn_click_public.setOnClickListener(MyOnClickListener(tv_result))}// 创建一个类 MyOnClickListener 来实现 View.OnClickListener 接口class MyOnClickListener(private val tv_result: TextView) : View.OnClickListener {override fun onClick(p0: View?) {val dsec String.format(%s 您点击了按钮 %s, DateUtil.getNowTime(), (p0 as Button).text)tv_result.text dsec // kotlin不用set()也不用get()}} }?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalButtonandroid:idid/btn_click_singleandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:text指定单独的点击监听器android:textColor#000000android:textSize15sp/Buttonandroid:idid/btn_click_publicandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:text指定公共的点击监听器android:textColor#000000android:textSize15sp/TextViewandroid:idid/tv_resultandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:padding5dpandroid:gravitycenterandroid:textColor#000000android:textSize15spandroid:text查看按钮点击的结果//LinearLayout结果
http://www.yutouwan.com/news/83171/

相关文章:

  • wordpress页面可视编辑wordpress seo自定义
  • 网站上传权限芜湖公司做网站
  • 庆阳网站设计报价网站设计能出来什么
  • 张家港高端网站建设16素材网
  • 广东企业备案 网站建设方案书口碑好的移动网站建设
  • 折再返怎么 做网站网站建设工作的作用
  • seo百度网站排名研究中心关键词首页优化移动端网站宽度做多大
  • 国外免费搭建网站源码wordpress 主题 her
  • 快速建设企业网站vs网站开发建表怎么肩啊
  • 灵璧哪有做网站的建站工具介绍
  • dw旅游网站模板超级优化大师
  • 做网站好还是做app好广州网站优化公司
  • 自己做网站需要做啥青岛市黄岛区建设局网站
  • 怎么弄公司网站搜狗指数官网
  • 爱射影院网站建设中杭州营销型网站建设
  • 企业网站建站技术网站内容管理系统怎么用
  • 做网站注册哪类商标做视频免费模板下载网站
  • 网站的功能包括哪些内容晋城市网站建设
  • 用vs2015做网站网站开发人员结构
  • 电商网站免费设计甘肃网站建设哪家好
  • 做搜狗pc网站快速开平市建设工程站网站
  • 济南做网站哪里好宿迁房产查询网上查询系统
  • 制作网站 太原网推项目
  • 长春一大网站商城网站建设是+什么软件
  • 企业网站广告图片轮播代码江门市骏业纸制品有限公司
  • 西安咪豆网站建设公司做软件工资高还是网站
  • 中劳网做网站做视频网站需要什么资质
  • 网站开发西安做医药代表去什么招聘网站
  • 备案查询网站做一个个人主页的网站怎么做
  • wordpress 网站播放器wordpress首页添加视频教程