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

河南网站优化排名我想在百度上发布广告怎么发

河南网站优化排名,我想在百度上发布广告怎么发,北京建设工程公司,做网站开发要学多久文章目录 准备工作一,创建Android Studio项目二,创建活动模块三,设计用户界面(一)设置页面布局(二)添加标题文本控件(三)设计体重输入框(四)设计性…

文章目录

  • 准备工作
  • 一,创建Android Studio项目
  • 二,创建活动模块
  • 三,设计用户界面
    • (一)设置页面布局
    • (二)添加标题文本控件
    • (三)设计体重输入框
    • (四)设计性别选项
    • (五)设计按钮和结果存放区
    • (六)运行查看效果
  • 四,编写活动代码
  • 五,运行项目


准备工作

  • 搭建开发环境
    JDK1.8,Android Studio

  • UI界面效果
    在这里插入图片描述

一,创建Android Studio项目

1,新建Android Studio项目,单击new Project。

在这里插入图片描述
2,选择phone and tablet——empty activity。

在这里插入图片描述

3,输入项目名称:HeightCalculator,语言选择Java,单击Finish。

在这里插入图片描述
4,等待下载全局配置依赖。

在这里插入图片描述5,下载完成,页面效果。
在这里插入图片描述6,单击运行按钮,启动项目,如下效果,成功创建项目。
在这里插入图片描述

二,创建活动模块

1,在项目目录右击选择——new——Activity——empty Activity。
在这里插入图片描述

2,输入名称:HeightCalculatorActivity,单击finish按钮,创建活动。
在这里插入图片描述
3,创建完成。
在这里插入图片描述

三,设计用户界面

(一)设置页面布局

1,进入code页,编写代码。
在这里插入图片描述
2,进入design页,可以使用拖动的方式添加布局方式和控件。
在这里插入图片描述
3,添加线性布局,根据效果图,页面整体布局为垂直;这里设置为垂直:android:orientation="vertical"
在这里插入图片描述

(二)添加标题文本控件

在这里插入图片描述源码:

<TextViewandroid:layout_width="410dp"android:layout_height="100dp"android:gravity="center"android:text="标准身高计算器"android:textAlignment="center"android:textSize="30sp"android:textStyle="bold" />

(三)设计体重输入框

1,根据下面效果图,这是一个水平布局,包含三个控件。
在这里插入图片描述
2,首先,先添加一个水平布局,android:orientation="horizontal",表示水平布局。
在这里插入图片描述

3,在水平布局下添加文本视图控件(相当于标签,显示文本)。
在这里插入图片描述
4,添加一个输入框控件,用于接收用户输入的数据,并且给上一个id值,后续编写Java代码接收信息。
在这里插入图片描述5,最后再添加一个文本视图控件,用于显示最后的单位。
在这里插入图片描述

(四)设计性别选项

1,分析:从下图中也可发现这是一个水平布局,并且两个单选按钮是绑定在一起的(如不是共同,则性别就可以全选,就失去了单选按钮的特点,出现逻辑错误)。
在这里插入图片描述
2,根据分析,此时再添加一个水平布局,二级的布局方式,与体重输入框布局属于同级。
在这里插入图片描述

<LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:orientation="horizontal"></LinearLayout>

3,添加文本视图控件。
在这里插入图片描述

<TextViewandroid:layout_width="150.0dip"android:layout_height="wrap_content"android:layout_gravity="center"android:text="请选择你的性别:"android:textSize="18sp" />

4,添加单选控件组,将两个单选按钮绑定到一起。
在这里插入图片描述

<RadioGroupandroid:id="@+id/RadioGroup01"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"></RadioGroup>

5,在控件组中添加两个单选按钮控件。
在这里插入图片描述

<RadioButton                       android:id="@+id/man"          android:layout_width="50.0dip" android:layout_height="70.0dip"android:checked="true"         android:text="" />            <RadioButton                       android:id="@+id/woman"        android:layout_width="50.0dip" android:layout_height="70.0dip"android:text="" />            

(五)设计按钮和结果存放区

1,添加水平布局,在布局下添加按钮控件。
在这里插入图片描述

<LinearLayout                               android:layout_width="fill_parent"      android:layout_height="wrap_content"    android:gravity="center_horizontal"     android:orientation="horizontal">       <Button                                 android:id="@+id/calculator"        android:layout_width="200.0dip"     android:layout_height="wrap_content"android:layout_marginTop="20.0dip"  android:text="运算 " />               
</LinearLayout>                             

2,添加水平布局,在其中添加文本视图控件用于存放结果(添加id)。
在这里插入图片描述

<LinearLayout                                android:layout_width="fill_parent"       android:layout_height="wrap_content"     android:gravity="center_horizontal"      android:orientation="horizontal">        <TextView                                android:id="@+id/result"             android:layout_width="wrap_content"  android:layout_height="wrap_content" android:layout_marginTop="10.0dip" />
</LinearLayout>                              

(六)运行查看效果

1,右击身高计算器的Java文件,单击运行按钮。
在这里插入图片描述
2,弹出如下提示,无法运行(原因是没有配置运行配置文件:AndroidManifest.xml)。
在这里插入图片描述
3,打开AndroidManifest.xml,设置android:exported="true",在单击运行按钮。
在这里插入图片描述
4,模拟器显示出正常页面,没有什么问题。
在这里插入图片描述

四,编写活动代码

编写HeightCalculatorActivity.java,实现计算标准身高。
在这里插入图片描述

package com.example.heightcalculator;import androidx.appcompat.app.AppCompatActivity;import android.app.AlertDialog;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;public class HeightCalculatorActivity extends AppCompatActivity {private Button calculatorButton;private EditText weightEditText;private RadioButton manRadioButton;private RadioButton womanRadioButton;private TextView resultTextView;private static final int EXIT=1;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_height_calculator);calculatorButton=(Button)findViewById(R.id.calculator);weightEditText=(EditText)findViewById(R.id.weight);manRadioButton=(RadioButton)findViewById(R.id.man);womanRadioButton=(RadioButton)findViewById(R.id.woman);resultTextView=(TextView)findViewById(R.id.result);}@Overrideprotected void onStart() {super.onStart();registerEvent();}private void registerEvent(){calculatorButton.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {if(!weightEditText.getText().toString().trim().equals("")){double weight=Double.parseDouble(weightEditText.getText().toString());StringBuffer sb=new StringBuffer();sb.append("------------评估结果----------- \n");if(manRadioButton.isChecked()){sb.append("男性标准身高:");double result=evaluateHeight(weight,"男");sb.append((int)result+"(厘米)");}else if(womanRadioButton.isChecked()){sb.append("女性标准身高:");double result=evaluateHeight(weight,"女");sb.append((int)result+"(厘米)");}resultTextView.setText(sb.toString());}else{showMessage("请输入体重!");}}});}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {menu.add(Menu.NONE, EXIT, Menu.NONE, "退出");return super.onCreateOptionsMenu(menu);}@Overridepublic boolean onOptionsItemSelected(MenuItem item) {if(item.getItemId()==EXIT){finish();//退出程序}return super.onOptionsItemSelected(item);}private double evaluateHeight(double weight,String sex){double height;if(sex=="男"){height=170-(62-weight)/0.6;}else{height =158-(52-weight)/0.5;}return height;}private void showMessage(String message){AlertDialog alert = new AlertDialog.Builder(this).create();alert.setTitle("系统信息");alert.setMessage(message);alert.setButton("确定", (dialog, whichButton) -> {});alert.show();}}

五,运行项目

1,单击运行按钮。
在这里插入图片描述
2,启动成功。在这里插入图片描述

3,输入体重,得出结果。
在这里插入图片描述

http://www.dt0577.cn/news/21259.html

相关文章:

  • 海报设计图片手绘简单短视频排名seo
  • 大兴网站开发公司长沙seo优化
  • wordpress 新建php文件大小郑州seo优化服务
  • 无锡做网站中企动力南京网站设计公司
  • 怎么样做网站赚钱软件推广的渠道是哪里找的
  • 腾讯企点qtrade网站内容优化怎么去优化呢
  • 境外网站 icp备案百度推广seo是什么意思
  • 网站适配手机成都网站seo收费标准
  • 唐山房地产网站建设网站推广及seo方案
  • 免费网站建设阿里云自己可以做网站推广吗
  • 做一个网站做少多少钱网站设计流程
  • 如何做旅游攻略网站最新舆情信息网
  • 有哪些做包装设计网站好些免费发广告的软件
  • 营销型网站具备的二大能力软文写作什么意思
  • 家在深圳歌词seo优化工具推荐
  • 垂直型b2b网站有哪些百度下载安装免费版
  • 关于网站建设投稿网络工具
  • 做网页到哪个网站找素材百度推广没有效果怎么办
  • 淮安做网站找哪家公司seo网站推广有哪些
  • 个人网站怎么做qq客服百度应用市场
  • 哪些产品可以做单页网站seo站外优化最主要的是什么
  • 做网上购物网站seo刷词工具在线
  • 微信公众号运营需要做什么互联网seo是什么
  • 长春公司建站模板宁德市委书记
  • wordpress用户注册设置密码同仁seo排名优化培训
  • 一个b2c网站多少钱产品营销网站建设
  • 用什么工具建设网站百度百家号怎么赚钱
  • 网站建设评比细则整站seo服务
  • 网站免费优化工具网站黄页推广软件
  • 做网站详细步骤链接搜索