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

给政府做网站/品牌营销策划包括哪些内容

给政府做网站,品牌营销策划包括哪些内容,廊坊公司做网站,020网站建设目录一、传递基本类型数据(一)编辑MainActivity(二)编辑InfoActivity(三)布局(四)效果二、传递对象(一)创建类(二)编辑MainActivity(三&#xff0…

目录

  • 一、传递基本类型数据
    • (一)编辑MainActivity
    • (二)编辑InfoActivity
    • (三)布局
    • (四)效果
  • 二、传递对象
    • (一)创建类
    • (二)编辑MainActivity
    • (三)编辑InfoActivity
    • (四)布局
    • (五)效果
  • 三、传递集合
    • (一)编辑MainActivity
    • (二)编辑InfoActivity
    • (三)布局
    • (四)真机效果

一、传递基本类型数据

(一)编辑MainActivity

在这里插入图片描述

  • 代码:
import androidx.appcompat.app.AppCompatActivity;import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;public class MainActivity extends AppCompatActivity {Button btn_submit;EditText name_edit;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);btn_submit = (Button) findViewById(R.id.btn_submit);name_edit = (EditText) findViewById(R.id.name_edit);btn_submit.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v){Intent intent = new Intent();intent.setClass(MainActivity.this,InfoActivity.class);String name = name_edit.getText().toString();intent.putExtra("name",name);startActivity(intent);}});}
}

(二)编辑InfoActivity

在这里插入图片描述

  • 代码:
import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;
import android.widget.TextView;public class InfoActivity extends AppCompatActivity {TextView infoshow;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_info);infoshow = (TextView) findViewById(R.id.infoshow);Bundle bundle = getIntent().getExtras();String name = bundle.getString("name");infoshow.setText(name);}
}

(三)布局

  • activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayoutxmlns: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:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><EditTextandroid:id="@+id/name_edit"android:layout_width="match_parent"android:layout_height="43dp"tools:layout_editor_absoluteX="156dp"tools:layout_editor_absoluteY="64dp"android:hint="  姓名"tools:ignore="MissingConstraints" /><Buttonandroid:id="@+id/btn_submit"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_x="268dp"android:layout_y="209dp"android:text="查看"tools:ignore="MissingConstraints"tools:layout_editor_absoluteX="161dp"tools:layout_editor_absoluteY="123dp"android:layout_weight="1"/>
</AbsoluteLayout>
  • activity_info.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"android:layout_height="match_parent"tools:context=".InfoActivity"><TextViewandroid:id="@+id/infoshow"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="@color/black"android:textSize="25sp"tools:ignore="MissingConstraints"tools:layout_editor_absoluteX="151dp"tools:layout_editor_absoluteY="2dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

(四)效果

在这里插入图片描述

注:模拟机上只能输入数字及英文,想测中文建议真机调试。

二、传递对象

(一)创建类

  • 右键→New→Java Class:
    在这里插入图片描述
  • 编写Student类:
    在这里插入图片描述
  • 设置接口:右键→Generate…→Getter and Setter
    在这里插入图片描述
    在这里插入图片描述
  • Student类代码:
import java.io.Serializable;public class Student implements Serializable {private  String name;private  int age;private  String score;Student(String name,int age,String score){this.name=name;this.age=age;this.score=score;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public String getScore() {return score;}public void setScore(String score) {this.score = score;}
}

(二)编辑MainActivity

在这里插入图片描述

  • 代码:
import androidx.appcompat.app.AppCompatActivity;import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;public class MainActivity extends AppCompatActivity {Button btn_submit;EditText name_edit;EditText age_edit;EditText score_edit;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);btn_submit = (Button) findViewById(R.id.btn_submit);name_edit = (EditText) findViewById(R.id.name_edit);age_edit = (EditText) findViewById(R.id.age_edit);score_edit = (EditText) findViewById(R.id.score_edit);btn_submit.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v){Intent intent = new Intent();intent.setClass(MainActivity.this,InfoActivity.class);String name = name_edit.getText().toString();int age = Integer.parseInt(age_edit.getText().toString());String score = score_edit.getText().toString();Student s = new Student(name,age,score);intent.putExtra("student",s);startActivity(intent);}});}
}

(三)编辑InfoActivity

在这里插入图片描述

  • 代码:
import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;
import android.widget.TextView;public class InfoActivity extends AppCompatActivity {TextView infoshow;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_info);infoshow = (TextView) findViewById(R.id.infoshow);Bundle bundle = getIntent().getExtras();Student s = (Student) bundle.get("student");infoshow.setText("姓名:"+s.getName()+"   年纪:"+s.getAge()+"   专业:"+s.getScore()+"\n");}
}

(四)布局

  • activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayoutxmlns: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:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><EditTextandroid:id="@+id/name_edit"android:layout_width="match_parent"android:layout_height="43dp"tools:layout_editor_absoluteX="156dp"tools:layout_editor_absoluteY="64dp"android:hint="  姓名"tools:ignore="MissingConstraints" /><EditTextandroid:id="@+id/age_edit"android:layout_width="match_parent"android:layout_height="43dp"android:layout_x="0dp"android:layout_y="65dp"android:hint="  年纪"android:inputType="number"tools:ignore="MissingConstraints"tools:layout_editor_absoluteX="156dp"tools:layout_editor_absoluteY="64dp" /><EditTextandroid:id="@+id/score_edit"android:layout_width="match_parent"android:layout_height="43dp"android:layout_x="2dp"android:layout_y="129dp"android:hint="  专业"tools:ignore="MissingConstraints"tools:layout_editor_absoluteX="156dp"tools:layout_editor_absoluteY="64dp" /><Buttonandroid:id="@+id/btn_submit"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_x="268dp"android:layout_y="209dp"android:text="查看"tools:ignore="MissingConstraints"tools:layout_editor_absoluteX="161dp"tools:layout_editor_absoluteY="123dp"android:layout_weight="1"/>
</AbsoluteLayout>
  • activity_info.xml代码不变

(五)效果

在这里插入图片描述

三、传递集合

(一)编辑MainActivity

在这里插入图片描述
在这里插入图片描述

  • 代码:
import androidx.appcompat.app.AppCompatActivity;import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;import java.util.ArrayList;public class MainActivity extends AppCompatActivity {Button btn_submit;Button btn_save;EditText name_edit;EditText age_edit;EditText score_edit;ArrayList<Student> students = new ArrayList<Student>();@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);btn_submit = (Button) findViewById(R.id.btn_submit);btn_save = (Button) findViewById(R.id.btn_save);name_edit = (EditText) findViewById(R.id.name_edit);age_edit = (EditText) findViewById(R.id.age_edit);score_edit = (EditText) findViewById(R.id.score_edit);btn_save.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {String name = name_edit.getText().toString();int age = Integer.parseInt(age_edit.getText().toString());String score = score_edit.getText().toString();Student s = new Student(name,age,score);students.add(s);name_edit.setText("");age_edit.setText("");score_edit.setText("");}});btn_submit.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v){Intent intent = new Intent();intent.setClass(MainActivity.this,InfoActivity.class);intent.putExtra("students",students);startActivity(intent);}});}
}

(二)编辑InfoActivity

在这里插入图片描述

  • 代码:
package com.example.phone4;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;
import android.widget.TextView;import java.util.ArrayList;public class InfoActivity extends AppCompatActivity {TextView infoshow;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_info);infoshow = (TextView) findViewById(R.id.infoshow);Bundle bundle = getIntent().getExtras();ArrayList<Student> students =(ArrayList<Student>) bundle.get("students");for (Student s:students){infoshow.append("姓名:"+s.getName()+"   年纪:"+s.getAge()+"   专业:"+s.getScore()+"\n");}}
}

(三)布局

  • activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayoutxmlns: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:layout_width="match_parent"android:layout_height="match_parent"tools:context=".InfoActivity"><EditTextandroid:id="@+id/name_edit"android:layout_width="match_parent"android:layout_height="43dp"tools:layout_editor_absoluteX="156dp"tools:layout_editor_absoluteY="64dp"android:hint="  姓名"tools:ignore="MissingConstraints" /><EditTextandroid:id="@+id/age_edit"android:layout_width="match_parent"android:layout_height="43dp"android:layout_x="0dp"android:layout_y="65dp"android:hint="  年纪"android:inputType="number"tools:ignore="MissingConstraints"tools:layout_editor_absoluteX="156dp"tools:layout_editor_absoluteY="64dp" /><EditTextandroid:id="@+id/score_edit"android:layout_width="match_parent"android:layout_height="43dp"android:layout_x="2dp"android:layout_y="129dp"android:hint="  专业"android:inputType="text"tools:ignore="MissingConstraints"tools:layout_editor_absoluteX="156dp"tools:layout_editor_absoluteY="64dp" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_x="3dp"android:layout_y="178dp"android:orientation="horizontal"><Buttonandroid:id="@+id/btn_submit"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_x="268dp"android:layout_y="209dp"android:text="查看"tools:ignore="MissingConstraints"tools:layout_editor_absoluteX="161dp"tools:layout_editor_absoluteY="123dp"android:layout_weight="1"/><Buttonandroid:id="@+id/btn_save"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_x="58dp"android:layout_y="211dp"android:text="保存"tools:ignore="MissingConstraints"tools:layout_editor_absoluteX="161dp"tools:layout_editor_absoluteY="123dp"android:layout_weight="1"/></LinearLayout>
</AbsoluteLayout>
  • activity_info.xml代码不变

(四)真机效果

在这里插入图片描述

http://www.lbrq.cn/news/1586161.html

相关文章:

  • 网站网页设计模板下载/互联网广告平台有哪些
  • 本科学计算机是做网站吗/湖南产品网络推广业务
  • web网站开发用什么软件/手机网站怎么优化关键词
  • 企业网站建设 法规/打开百度搜索引擎
  • 没有公司个人可以做网站卖东西吗/潍坊seo教程
  • 赤峰网站建设red/如何做网站推广
  • 手表网站布局/成都网站关键词推广
  • php做的静态网站怎么加密/seo优化思路
  • 公司做网站需要准备什么资料/app推广平台
  • 济南网站建设网站制作/电商网站怎样优化
  • bob网站建设/伟哥seo博客
  • 哈尔滨网站建设价格低/seo全国最好的公司
  • 课程网站建设/企业网站建设论文
  • wordpress图片付费主题/北京seo优化诊断
  • 二手车做的好的网站有哪些/优化设计电子课本
  • frontpage如何做网站/高端网站建设报价
  • 选择ssm框架做网站的好处/企业网站建设的流程
  • 做a的视频在线观看网站/seo描述是什么意思
  • 青岛市建设局网站/免费源码网站
  • wordpress横线/合肥网站优化软件
  • 梧州网站建设定制/cms
  • 常州网站建设最易/深圳关键词优化
  • 网站内页的设计/西安优化外
  • 临海如何制作公司网站框架/手机百度关键词优化
  • dede网站后台模板/全网整合营销平台
  • 在线观看免费网站/长沙网红奶茶
  • window服务器如何做网站访问/怎么做一个自己的网页
  • 电子商务网站建设 论文/百度网址收录入口
  • 论职能网站建设/百度推广登陆
  • 建设旅游服务类网站的可行性报告/舆情分析网站
  • ​​《深入浅出K-means算法:从原理到实战全解析》​预告(提纲)
  • 学习Java的Day27
  • 数据库入门:从零开始构建你的第一个数据库
  • 芯片分享【昆泰】——CH7305A -display controller device.
  • 简单spring boot项目,之前练习的,现在好像没有达到效果
  • AI学习之大话transformer架构