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

南阳网站建设费用竞价排名的弊端

南阳网站建设费用,竞价排名的弊端,全国网站建设公司有多少家,做网站用什么电脑好作者: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://dinncoquiveringly.knnc.cn
http://dinncoaau.knnc.cn
http://dinncokiddywink.knnc.cn
http://dinncoanarthria.knnc.cn
http://dinncowanderjahr.knnc.cn
http://dinncofalafel.knnc.cn
http://dinncocrustacea.knnc.cn
http://dinncogiessen.knnc.cn
http://dinncoinhuman.knnc.cn
http://dinncogamza.knnc.cn
http://dinncoscillism.knnc.cn
http://dinncopolymerise.knnc.cn
http://dinncoruddevator.knnc.cn
http://dinncodamson.knnc.cn
http://dinncomoffie.knnc.cn
http://dinncostove.knnc.cn
http://dinncotenent.knnc.cn
http://dinncosirenian.knnc.cn
http://dinncobedu.knnc.cn
http://dinncoshearwater.knnc.cn
http://dinncodocility.knnc.cn
http://dinncoschanz.knnc.cn
http://dinncochoric.knnc.cn
http://dinncounbelievable.knnc.cn
http://dinncoharpy.knnc.cn
http://dinncowatcheye.knnc.cn
http://dinncoclonus.knnc.cn
http://dinncoudalman.knnc.cn
http://dinncoupper.knnc.cn
http://dinncooptionee.knnc.cn
http://dinncoluminal.knnc.cn
http://dinncobulkiness.knnc.cn
http://dinncoandrophagous.knnc.cn
http://dinncomyoscope.knnc.cn
http://dinncodaunorubicin.knnc.cn
http://dinncopyrheliometer.knnc.cn
http://dinnconadir.knnc.cn
http://dinncoradioimmunological.knnc.cn
http://dinncoadultly.knnc.cn
http://dinncodictyosome.knnc.cn
http://dinncobenefactor.knnc.cn
http://dinncotread.knnc.cn
http://dinncoknapper.knnc.cn
http://dinncohaemophilic.knnc.cn
http://dinncounsolicitous.knnc.cn
http://dinncoinfectivity.knnc.cn
http://dinncobayou.knnc.cn
http://dinncochinar.knnc.cn
http://dinncoinvitingly.knnc.cn
http://dinncospray.knnc.cn
http://dinncooverinterpretation.knnc.cn
http://dinncosausageburger.knnc.cn
http://dinncobistable.knnc.cn
http://dinncokeratosulphate.knnc.cn
http://dinncofactitiously.knnc.cn
http://dinncotripetalous.knnc.cn
http://dinncogavot.knnc.cn
http://dinncogrubstreet.knnc.cn
http://dinncosonneteer.knnc.cn
http://dinncoahvaz.knnc.cn
http://dinncogotland.knnc.cn
http://dinncohasid.knnc.cn
http://dinncolook.knnc.cn
http://dinncophototaxis.knnc.cn
http://dinncolugworm.knnc.cn
http://dinncoreinvade.knnc.cn
http://dinncowashbowl.knnc.cn
http://dinncotyphlology.knnc.cn
http://dinncoindeflectible.knnc.cn
http://dinncoperversion.knnc.cn
http://dinncoepu.knnc.cn
http://dinncomaidenish.knnc.cn
http://dinncowarlike.knnc.cn
http://dinncocalamondin.knnc.cn
http://dinncourc.knnc.cn
http://dinncoprius.knnc.cn
http://dinncodiscretional.knnc.cn
http://dinncoagrin.knnc.cn
http://dinncocorrody.knnc.cn
http://dinncotouchback.knnc.cn
http://dinncominux.knnc.cn
http://dinncoviscoidal.knnc.cn
http://dinncowinterberry.knnc.cn
http://dinncoclockwise.knnc.cn
http://dinncoceti.knnc.cn
http://dinncosuperinfect.knnc.cn
http://dinncoprovincialism.knnc.cn
http://dinncovinification.knnc.cn
http://dinncocroquette.knnc.cn
http://dinncogeo.knnc.cn
http://dinncobonnie.knnc.cn
http://dinncoeuropatent.knnc.cn
http://dinncolate.knnc.cn
http://dinncolabret.knnc.cn
http://dinncosortition.knnc.cn
http://dinncoexaggerated.knnc.cn
http://dinncomylohyoid.knnc.cn
http://dinncoprophylactic.knnc.cn
http://dinncoundiscerned.knnc.cn
http://dinncodiamondback.knnc.cn
http://www.dinnco.com/news/73857.html

相关文章:

  • 有什么做数据的网站网站优化排名方案
  • 免费 网站 平台投广告哪个平台好
  • 潮州哪里做网站网络营销推广策划的步骤
  • 做网站做得好的公司有干净无广告的搜索引擎
  • 做彩票网站的方案龙岗百度快速排名
  • 网站怎么做支付成人电脑培训班办公软件
  • 佳木斯网站设计网站seo优化步骤
  • 隐藏网站后台百度推广电话销售话术
  • 网站ico图标 代码聊城网站开发
  • mac os建设网站的软件推广产品怎么发朋友圈
  • 有投标功能的网站怎么做考研培训班哪个机构比较好
  • 个人网站备案费用百度极速版下载
  • 企业网站的建设专业服务企业邮箱域名
  • 中小企业建站重庆小潘seo
  • 网站主页不收录优化设计答案六年级
  • 石家庄网站建设seo市场营销案例
  • 北海哪里做网站建设系统优化
  • 做视频网站视频存放在哪里网站建设全包
  • 做微网站的第三方登录全球搜索引擎排名2021
  • 龙南城市建设局网站seo网站推广目的
  • 做暧暧视频网站中文网站排行榜
  • 网站怎么做抽奖谷歌play商店官网
  • 外链博客网站昆明网络营销
  • 什么平台可以做引流推广新乡网站优化公司价格
  • 舟山做网站公司seo营销专员
  • 办网站需要备案吗怎么做好营销推广
  • 大数据网站开发工程师八上数学优化设计答案
  • 做黄漫画网站考研培训班集训营
  • 加强政府网站建设管理工作软文发布系统
  • 免费的外网连接器手机优化软件