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

户外运动网站模板html5安卓软件下载

户外运动网站模板,html5安卓软件下载,广东省建筑企业资质查询平台,深圳公司网站建设哪里专业作者#xff1a;CSDN-PleaSure乐事 欢迎大家阅读我的博客 希望大家喜欢 使用环境#xff1a;AndroidStudio 目录 1.新建活动 2.修改页面布局 代码#xff1a; 效果#xff1a; 3.新建类ResultActivity并继承AppCompatActivity 4.新建布局文件activity_result.xml 代… 作者CSDN-PleaSure乐事 欢迎大家阅读我的博客 希望大家喜欢 使用环境AndroidStudio 目录 1.新建活动 2.修改页面布局 代码 效果 3.新建类ResultActivity并继承AppCompatActivity 4.新建布局文件activity_result.xml 代码 5.修改MainActivity和ResultActivity代码 6.最终效果展示 1.新建活动 新建一个工程LabActivityDataTransfer也可以是你自己创建的活动允许AndroidStudio帮我们自动创建活动创建的活动名布局名为默认值MainActivity和activity_main.xml。 2.修改页面布局 在activity_main.xml中我们可以修改页面布局例如我们按照如下方法就可以写出一个最基本的手机用户信息的界面 代码 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:idid/mainandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticaltools:context.MainActivityandroid:layout_marginTop30dpTextViewandroid:idid/tx_1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text请输入你的注册信息android:textSize30dp/LinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentTextViewandroid:idid/tv2android:layout_widthwrap_contentandroid:layout_height50dpandroid:text用户名android:textSize18sp/EditTextandroid:idid/nameandroid:layout_widthmatch_parentandroid:layout_height50dpandroid:hint请填写您想要注册的账号android:textSize18sp//LinearLayoutLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentTextViewandroid:idid/tv1android:layout_widthwrap_contentandroid:layout_height50dpandroid:text 密码android:textSize18sp/EditTextandroid:idid/passwordandroid:layout_widthmatch_parentandroid:layout_height50dpandroid:inputTypenumber//LinearLayoutLinearLayoutandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:orientationhorizontalTextViewandroid:idid/tx_4android:layout_widthmatch_parentandroid:layout_height50dpandroid:text 性别:android:textSize18sp/RadioGroupandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalRadioButtonandroid:idid/maleandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text男android:textSize18sp /RadioButtonandroid:idid/femaleandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text女android:textSize18sp //RadioGroup/LinearLayoutButtonandroid:idid/registerandroid:layout_widthmatch_parentandroid:layout_height50dpandroid:text注册 / /LinearLayout 效果 3.新建类ResultActivity并继承AppCompatActivity 在ResultActivity当中我们需要重写onCreate()方法在其中加载布局activity_result。 4.新建布局文件activity_result.xml 新建布局文件activity_result.xml的目的是用来接收传来的数据用TextView显示接收到的注册信息。 代码 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalTextViewandroid:idid/textNameandroid:layout_widthwrap_contentandroid:layout_heightwrap_content/TextViewandroid:idid/textPasswdandroid:layout_widthwrap_contentandroid:layout_heightwrap_content/TextViewandroid:idid/textGenderandroid:layout_widthwrap_contentandroid:layout_heightwrap_content/ /LinearLayout 随后在mainfest文件当中注册ResultActivity activity android:name.ResultActivity/activity 5.修改MainActivity和ResultActivity代码 修改MainActivity中的代码获取注册数据并保存到Bundle对象将其放入Intent传递给下一个活动ResultActivity。 Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);EdgeToEdge.enable(this);setContentView(R.layout.activity_main);Button btn_reg(Button)findViewById(R.id.register);btn_reg.setOnClickListener(new View.OnClickListener () {Overridepublic void onClick(View view) {EditText name (EditText)findViewById(R.id.name);EditText passwd (EditText)findViewById(R.id.password);RadioButton male (RadioButton) findViewById(R.id.male);String gender male.isChecked()?男:女;// 创建 Bundle 对象并添加数据Bundle bundle new Bundle();bundle.putString(name, name.getText().toString());bundle.putString(password, passwd.getText().toString());bundle.putString(gender, gender);// 创建 Intent 并设置目标活动Intent intent new Intent(MainActivity.this, ResultActivity.class);intent.putExtras(bundle); // 将 Bundle 放入 Intent// 启动 ResultActivitystartActivity(intent);}});ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) - {Insets systemBars insets.getInsets(WindowInsetsCompat.Type.systemBars());v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);return insets;});} 随后ResultActivity代码在onCreate()方法中获取注册数据并显示。 Overrideprotected void onCreate(Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_result);Bundle bundle getIntent().getExtras();if (bundle ! null) {// 从 Bundle 中获取数据String name bundle.getString(name);String password bundle.getString(password);String gender bundle.getString(gender);// 找到布局中的 TextViewTextView textName findViewById(R.id.textName);TextView textPassword findViewById(R.id.textPasswd);TextView textGender findViewById(R.id.textGender);// 设置数据到 TextViewif (textName ! null) {textName.setText(name);}if (textPassword ! null) {textPassword.setText(password);}if (textGender ! null) {textGender.setText(gender);}}} 这样也就完成了数据传递。 6.最终效果展示 7.注意点 我们在本次试验中一定要注意数据的接收等同时要保证对各个ID的设置避免混淆等情况的出现。最开始博主就是ID各种设错导致数据没有正常传递。 同时我们使用liner线性布局的时候要注意横向和纵向的区别。最开始博主不小心把纵向的设置为横向了导致最后数据显示已经有了当时被挤到屏幕外了一度非常尴尬。 作者CSDN-PleaSure乐事 希望我的博客对您有帮助也希望在对您有帮助时您可以为我留下点赞收藏与关注这对我真的很重要谢谢
http://www.hkea.cn/news/14529422/

相关文章:

  • 做网站空间需要多大有哪些免费的视频网站
  • 学校要求做网站做微博推广的网站吗
  • 襄阳旅游景点网站建设关注公众号一单一结兼职
  • 百度验证网站saas系统是什么模式
  • 百度微信官网网站模板wordpress 存储视频
  • 一键建站源码做外贸怎样浏览国外网站
  • wordpress 4.6.1关键词优化是什么
  • 绿建设计院网站h5开发入门
  • 网站整合discuz高端视觉网站
  • 网站开发弹窗制作古城做网站的公司
  • 辽宁网站优化新干线快递国内如何查单
  • 南京网站设计制作公司排名榜湟源县网站建设
  • 怎么在百度搜索自己的网站那个网站可以做全景图
  • 什么网站百度收录好网络建站培训
  • 网站开发服务器知识在百度上建网站
  • 购物网站开发周期网站建设公司词
  • 企业网站管理系统标签手册专业网站运营设计
  • 建设银行网站官网锦州网站建设报价
  • 丰都网站建设公司搜索引擎网站的搜素结果有何区别
  • 深圳龙岗高端网站建设东营会计信息网官网首页
  • 找人做公司网站logo设计公司排名
  • ui动效网站网站建设服务好的商家
  • 什么网站不能备案用wordpress搭建目录网站
  • 网站解析 cname网站快速建设入门教程
  • 扫二维码做自己网站wordpress 3.1.3
  • 简洁手机导航网站模板下载安装服务器怎么租用
  • 有哪些网站或者公司招募做视频的营销型网站怎么收费标准
  • 手机网站加速器软件发布流程
  • 网站建设心得体会及总结网站建设与管理吴振峰ppt
  • 百度网站地图生成器青岛seo网站排名