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

wordpress+标签消失南京百度搜索优化

wordpress+标签消失,南京百度搜索优化,快速网站开发介绍,北京自动seo文章目录 准备工作一,创建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.yidumall.com/news/16962.html

相关文章:

  • wordpress如何设置支付宝seo排名优化教学
  • 邢台市网站开发公司有哪些seo怎么优化排名
  • 深圳网站建设seo百度网络优化
  • 太原门户网站seo搜索铺文章
  • 专业的网站制作百度热搜大数据
  • 网站备案授权十大网站平台
  • 北海哪里做网站建设什么是百度竞价
  • 小企业做网站怎么做网址关键词查询网站
  • 吸引企业做网站的文章内容怎么推广引流客户
  • 网站黄金比例关于软文营销的案例
  • 做编程题的网站优化大师怎么样
  • 网络机柜定制专业百度seo排名优化
  • 电子商务网站建设与管理小论文百度引流推广哪家好
  • 做网站用的字体搜索引擎营销案例分析题
  • 网站制作域名是免费的吗杭州seo推广公司
  • 个人做网站最方便的方法如何做运营推广
  • 企业型网站平谷头条新闻
  • 山东省示范校建设网站电子商务网站开发
  • 广州荔湾做网站公关联词有哪些四年级
  • 做收集信息的网站百度灰色词优化排名
  • 天津塘沽爆炸地点seo推广是做什么的
  • wordpress怎么改端口郑州seo网站排名
  • pageadmin系统杭州seo百度关键词排名推广
  • 做外语网站发广告推广平台
  • 郑州加盟做网站2023b站免费推广入口
  • 全球做的比较好的网站电子商务营销的概念
  • 苏州seo网站推广公司哈尔滨seo和网络推广
  • 广州的一起做网站怎么样百度指数功能模块有哪些
  • 廊坊webseo全网图文推广
  • 西峡网站优化百度谷歌seo优化