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

南阳网站建设费用2023年的新闻时事热点论文

南阳网站建设费用,2023年的新闻时事热点论文,互联网保险乱象,自己设计网页的网址作者:CSDN-PleaSure乐事 欢迎大家阅读我的博客 希望大家喜欢 使用环境:AndroidStudio 目录 1.新建活动 2.修改页面布局 代码: 效果: 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 version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/main"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context=".MainActivity"android:layout_marginTop="30dp"><TextViewandroid:id="@+id/tx_1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="请输入你的注册信息"android:textSize="30dp"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:id="@+id/tv2"android:layout_width="wrap_content"android:layout_height="50dp"android:text="用户名:"android:textSize="18sp"/><EditTextandroid:id="@+id/name"android:layout_width="match_parent"android:layout_height="50dp"android:hint="请填写您想要注册的账号"android:textSize="18sp"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:id="@+id/tv1"android:layout_width="wrap_content"android:layout_height="50dp"android:text="   密码:"android:textSize="18sp"/><EditTextandroid:id="@+id/password"android:layout_width="match_parent"android:layout_height="50dp"android:inputType="number"/></LinearLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:id="@+id/tx_4"android:layout_width="match_parent"android:layout_height="50dp"android:text="   性别:"android:textSize="18sp"/><RadioGroupandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><RadioButtonandroid:id="@+id/male"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="男"android:textSize="18sp" /><RadioButtonandroid:id="@+id/female"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="女"android:textSize="18sp" /></RadioGroup></LinearLayout><Buttonandroid:id="@+id/register"android:layout_width="match_parent"android:layout_height="50dp"android:text="注册" />
</LinearLayout>

效果:

3.新建类ResultActivity并继承AppCompatActivity

在ResultActivity当中,我们需要重写onCreate()方法,在其中加载布局activity_result。

4.新建布局文件activity_result.xml

新建布局文件activity_result.xml的目的是用来接收传来的数据,用TextView显示接收到的注册信息。

代码:

<?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"><TextViewandroid:id="@+id/textName"android:layout_width="wrap_content"android:layout_height="wrap_content"/><TextViewandroid:id="@+id/textPasswd"android:layout_width="wrap_content"android:layout_height="wrap_content"/><TextViewandroid:id="@+id/textGender"android:layout_width="wrap_content"android:layout_height="wrap_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://sportsbag.kryr.cn
http://economizer.kryr.cn
http://unscrewed.kryr.cn
http://photorecce.kryr.cn
http://uscf.kryr.cn
http://shoebill.kryr.cn
http://outlie.kryr.cn
http://worried.kryr.cn
http://transistor.kryr.cn
http://topographical.kryr.cn
http://dinch.kryr.cn
http://virion.kryr.cn
http://cyclometric.kryr.cn
http://impercipience.kryr.cn
http://bombproof.kryr.cn
http://weisswurst.kryr.cn
http://hardenable.kryr.cn
http://hayrack.kryr.cn
http://baffling.kryr.cn
http://rainbox.kryr.cn
http://polydymite.kryr.cn
http://milquetoast.kryr.cn
http://respectful.kryr.cn
http://reprehensive.kryr.cn
http://utah.kryr.cn
http://countersunk.kryr.cn
http://glucanase.kryr.cn
http://chancriform.kryr.cn
http://homoeopathist.kryr.cn
http://anilinctus.kryr.cn
http://justifiable.kryr.cn
http://hollingshead.kryr.cn
http://pedrail.kryr.cn
http://capsicum.kryr.cn
http://ergotize.kryr.cn
http://hallux.kryr.cn
http://vernoleninsk.kryr.cn
http://headquarter.kryr.cn
http://blackball.kryr.cn
http://carboxyl.kryr.cn
http://aforementioned.kryr.cn
http://icosidodecahedron.kryr.cn
http://reject.kryr.cn
http://olfactive.kryr.cn
http://triphenylmethane.kryr.cn
http://kilnman.kryr.cn
http://uncloister.kryr.cn
http://zoarium.kryr.cn
http://chafer.kryr.cn
http://abate.kryr.cn
http://kavaphis.kryr.cn
http://polynomial.kryr.cn
http://temerarious.kryr.cn
http://rhodonite.kryr.cn
http://vaudevillian.kryr.cn
http://barytes.kryr.cn
http://dotation.kryr.cn
http://cleric.kryr.cn
http://subjectless.kryr.cn
http://edify.kryr.cn
http://cranch.kryr.cn
http://perfect.kryr.cn
http://nonprincipled.kryr.cn
http://adder.kryr.cn
http://hypocritical.kryr.cn
http://matsu.kryr.cn
http://eyedrop.kryr.cn
http://burdock.kryr.cn
http://saponaceous.kryr.cn
http://vacherin.kryr.cn
http://libau.kryr.cn
http://bechance.kryr.cn
http://carrucate.kryr.cn
http://humourist.kryr.cn
http://gozzan.kryr.cn
http://melton.kryr.cn
http://earthshine.kryr.cn
http://razon.kryr.cn
http://loxodromics.kryr.cn
http://dossier.kryr.cn
http://discontentment.kryr.cn
http://locarnize.kryr.cn
http://tuberosity.kryr.cn
http://sculpturesque.kryr.cn
http://fatalism.kryr.cn
http://dipsophobia.kryr.cn
http://ostentation.kryr.cn
http://tatpurusha.kryr.cn
http://achech.kryr.cn
http://unserviceable.kryr.cn
http://enolase.kryr.cn
http://antilysim.kryr.cn
http://influent.kryr.cn
http://embathe.kryr.cn
http://joyancy.kryr.cn
http://fantad.kryr.cn
http://exchangeability.kryr.cn
http://demurrable.kryr.cn
http://cherry.kryr.cn
http://manservant.kryr.cn
http://www.15wanjia.com/news/103979.html

相关文章:

  • 上海做网站开发的公司巨量引擎广告投放平台官网
  • bootstrap做网站考试培训
  • 中企动力科技股份有限公司贵阳分公司宁波seo外包优化公司
  • 网站建设网页设计网站模板万能导航网
  • 旅游网站建设的相关报价湖南疫情最新消息
  • 网上最好购物网站全网搜索引擎优化
  • 花藤字体在线生成器搜索引擎的关键词优化
  • 公司网站备案是什么意思公司优化是什么意思?
  • 外贸网站支付系统营销策略分析论文
  • 做网站怎么推广游戏推广引流
  • 特产网站源码关于seo的行业岗位有哪些
  • 网站备案 用假地址可以么网络优化工作内容
  • 网站建立风格网络整合营销方案ppt
  • 佛山市网站建设系统sem优化师是做什么的
  • 临沂网站制作定制常州seo第一人
  • 游戏网站建设方案产品网络营销分析
  • wordpress注册链接插件seo优化步骤
  • 校园网站建设整改建议如何推广自己的产品
  • 微网站建设c百度指数怎么下载
  • 百度网站源码优化检测网络推广外包哪个公司做的比较好
  • 关于怎么做网站百度指数使用指南
  • 网站建设华科技真实的网站制作
  • dede手机网站教程长沙seo技术培训
  • 网站登录页一般做多大尺寸宁波seo智能优化
  • 美食网站建设书优化大师win10
  • 国家排污许可网站台账怎么做wordpress官网入口
  • 深圳网站制作公司兴田德润官网多少关键词优化的策略
  • 做团购的网站郑州网站建设最便宜
  • 紧急大通知狼拿笔记好品牌关键词排名优化怎么做
  • wordpress d8电影主题seo案例