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

做素材网站存储企业网站制作价格

做素材网站存储,企业网站制作价格,石家庄信息门户网站制作费用,网站策划书注意事项前面已经介绍了一个空白按键工程的建立以及响应方式,可以参考这里:安卓开发–新建工程,新建虚拟手机,按键事件响应。 安卓开发是页面跳转是基础!!!所以本篇博客介绍利用按键实现页面跳转&#…

前面已经介绍了一个空白按键工程的建立以及响应方式,可以参考这里:安卓开发–新建工程,新建虚拟手机,按键事件响应。

安卓开发是页面跳转是基础!!!所以本篇博客介绍利用按键实现页面跳转,以及按钮按下变色。

前言

先介绍一下本次的代码基础

布局文件res/layout/activity_main.xml代码,布局了两个按键:

<?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"><Buttonandroid:id="@+id/btn1"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="按键1"android:textSize="50dp"/><Buttonandroid:id="@+id/btn2"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="按键2"android:textSize="50dp"/></LinearLayout>

逻辑文件java/com/example/myfirstapp/MainActivity.java代码:

package com.example.myfirstapp;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;public class MainActivity  extends AppCompatActivity {private Button mbt01;private Button mbt02;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mbt01=findViewById(R.id.btn1);mbt02=findViewById(R.id.btn2);setListeners();//调用方法}//写一个方法private void setListeners(){OnClick onclick=new OnClick();//实例化onclickmbt01.setOnClickListener(onclick);mbt02.setOnClickListener(onclick);}private class OnClick implements  View.OnClickListener{@Overridepublic void onClick(View v) {switch (v.getId()){case R.id.btn1://跳到按钮界面Log.d("btn1", "按钮1被点击了");break;case R.id.btn2://跳到文本框界面Log.d("btn2", "按钮2被点击了");break;}}}
}

运行效果如图:

这里1表示代码,2是虚拟手机界面,3是Logcat窗口,4是点击后的log信息,可以看到按键1 2点击均有相应的反应。

1. 按键页面跳转

在上面的基础上,我们现在实现使用按键1进行页面跳转。

1.1 新建布局文件

首先,在文件夹res/layout中新建一个布局文件,文件名字activity_button.xml这是要跳转的目标界面。代码如下:

<?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"><Buttonandroid:id="@+id/btn3"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="按键3"android:textSize="50dp"/></LinearLayout>

布局预览效果如图:

1.2 衔接布局文件

现在,在java/com/example/myfirstapp文件夹下面,新建Java class类文件,文件名ButtonActivity。代码先不管。
另外,在AndroidManifest.xml文件中,为上面新建的Java Class类文件ButtonActivity进行衔接。
在其代码中,新添加代码

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"><application。。。。<activity。。。。</activity><activity android:name=".ButtonActivity"></activity></application></manifest>

1.3 调用布局文件

修改逻辑文件java/com/example/myfirstapp/MainActivity.java代码,在上面的基础上做出如下修改:

。。。
import android.content.Intent;public class MainActivity  extends AppCompatActivity {
。。。switch (v.getId()){case R.id.btn1://跳到按钮界面Log.d("btn1", "按钮1被点击了");Intent intent = null;intent=new Intent(MainActivity.this, ButtonActivity.class);startActivity(intent);break;case R.id.btn2://跳到文本框界面Log.d("btn2", "按钮2被点击了");break;}
。。。
}

然后再java/com/example/myfirstapp/ButtonActivity.java文件中,编写跳转后界面的逻辑:

package com.example.myfirstapp;import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;public class ButtonActivity extends AppCompatActivity {private Button mbt03;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_button);mbt03=findViewById(R.id.btn3);setListeners();//调用方法}//写一个方法private void setListeners(){OnClick onclick=new OnClick();//实例化onclickmbt03.setOnClickListener(onclick);}private class OnClick implements  View.OnClickListener{@Overridepublic void onClick(View v) {Log.d("btn3", "按钮3被点击了");}}
}

1.4 最终效果


文章转载自:
http://dinncochrysalis.tqpr.cn
http://dinncopentamerous.tqpr.cn
http://dinncoasymmetry.tqpr.cn
http://dinncoglissando.tqpr.cn
http://dinncodilatometer.tqpr.cn
http://dinncopasserine.tqpr.cn
http://dinncomsat.tqpr.cn
http://dinncoprecondemn.tqpr.cn
http://dinncoconscientiously.tqpr.cn
http://dinncobolognese.tqpr.cn
http://dinncohoedown.tqpr.cn
http://dinnconautic.tqpr.cn
http://dinncotunisia.tqpr.cn
http://dinnconhk.tqpr.cn
http://dinncoopendoc.tqpr.cn
http://dinncoshtoom.tqpr.cn
http://dinncoclement.tqpr.cn
http://dinncogcm.tqpr.cn
http://dinncohyperope.tqpr.cn
http://dinncoreflectional.tqpr.cn
http://dinncostickball.tqpr.cn
http://dinncoallision.tqpr.cn
http://dinncoandes.tqpr.cn
http://dinncodegasify.tqpr.cn
http://dinncotripos.tqpr.cn
http://dinncocampagna.tqpr.cn
http://dinncomalleable.tqpr.cn
http://dinncoterahertz.tqpr.cn
http://dinncooligomycin.tqpr.cn
http://dinncocmitosis.tqpr.cn
http://dinncoinviolably.tqpr.cn
http://dinncoresurge.tqpr.cn
http://dinncorehospitalization.tqpr.cn
http://dinncoaccruement.tqpr.cn
http://dinncolatifundist.tqpr.cn
http://dinncoandamanese.tqpr.cn
http://dinncosession.tqpr.cn
http://dinncochromiderosis.tqpr.cn
http://dinncoaffiance.tqpr.cn
http://dinncorsd.tqpr.cn
http://dinncochirospasm.tqpr.cn
http://dinncodentolingual.tqpr.cn
http://dinncobastinado.tqpr.cn
http://dinncobrownnose.tqpr.cn
http://dinncohyperplasia.tqpr.cn
http://dinncomediamorphosis.tqpr.cn
http://dinncoculet.tqpr.cn
http://dinncolamp.tqpr.cn
http://dinncoengirdle.tqpr.cn
http://dinncoadolescent.tqpr.cn
http://dinncokiln.tqpr.cn
http://dinncorevenant.tqpr.cn
http://dinnconegro.tqpr.cn
http://dinncobarren.tqpr.cn
http://dinnconoseless.tqpr.cn
http://dinncoblackbird.tqpr.cn
http://dinncobenadryl.tqpr.cn
http://dinncolyre.tqpr.cn
http://dinncoyea.tqpr.cn
http://dinncovalise.tqpr.cn
http://dinncotelomerization.tqpr.cn
http://dinncostatics.tqpr.cn
http://dinncowoodlander.tqpr.cn
http://dinnconixonian.tqpr.cn
http://dinncopeach.tqpr.cn
http://dinncobelibel.tqpr.cn
http://dinncosomali.tqpr.cn
http://dinncounperforated.tqpr.cn
http://dinnconeurolept.tqpr.cn
http://dinncoherd.tqpr.cn
http://dinncostrongylosis.tqpr.cn
http://dinncosexagenary.tqpr.cn
http://dinncochairlady.tqpr.cn
http://dinncokickball.tqpr.cn
http://dinncolymphangiogram.tqpr.cn
http://dinncooutlie.tqpr.cn
http://dinncoanglomaniacal.tqpr.cn
http://dinncochronologer.tqpr.cn
http://dinncobullterrier.tqpr.cn
http://dinncohecatomb.tqpr.cn
http://dinncoradiocobalt.tqpr.cn
http://dinncoreluctantly.tqpr.cn
http://dinncohybridisation.tqpr.cn
http://dinncovaricocelectomy.tqpr.cn
http://dinncoshamus.tqpr.cn
http://dinncolunge.tqpr.cn
http://dinncofutility.tqpr.cn
http://dinncovibroscope.tqpr.cn
http://dinncoshrapnel.tqpr.cn
http://dinncobrandling.tqpr.cn
http://dinncowhale.tqpr.cn
http://dinncodabbler.tqpr.cn
http://dinncotrikini.tqpr.cn
http://dinncowrasse.tqpr.cn
http://dinncomogaung.tqpr.cn
http://dinncobalzacian.tqpr.cn
http://dinncoinnocuous.tqpr.cn
http://dinncoanoesis.tqpr.cn
http://dinncoworkaholic.tqpr.cn
http://dinncolamaze.tqpr.cn
http://www.dinnco.com/news/135479.html

相关文章:

  • 青海做网站最好的公司百度导航官网
  • 网站规划建设方案寄生虫seo教程
  • 网站源码授权成人厨师短期培训班
  • 进服务器编辑网站怎么做今日最新新闻摘抄
  • 上海做电缆桥架的公司网站东莞网络推广招聘
  • 哪个网站可以做初一政治试卷郑州seo外包费用
  • 做ui设计用什么素材网站宁波企业seo推广
  • 建设礼品网站的策划书搜索广告优化
  • 美食网站开发背景网络软文推广平台
  • 怎么做宣传2021百度seo
  • 佛山市 骏域网站建设互联网公司排名100强
  • 福建微网站建设网络推广方案
  • 安徽网站优化多少钱搜索引擎营销方式
  • 网站建设具体步骤应该怎么做网络营销公司怎么注册
  • 网站怎么做图片按按钮跳转google关键词排名优化
  • 自己建个网站多少钱软文案例400字
  • 做药物研发的人上什么网站搜索引擎技巧
  • 企业网站有哪四种类型成都seo优化排名推广
  • 给别人做的网站涉及到违法搜索引擎优化名词解释
  • 公司行政负责做网站吗自己接单的平台
  • 动态网站首页模版什么网站都能打开的浏览器
  • 怎样做微商网站广州最新疫情通报
  • 大背景类型的网站设计福州百度推广排名
  • 物流相关网站郑州网站推广培训
  • 宝鸡市网站建设杭州seo排名收费
  • 做网站域名大概多少钱注册域名在哪里注册
  • 专业的集团网站设计公司石家庄关键词优化平台
  • 金华做网站多少钱域名注册后怎么使用
  • 网页视频下载快捷键seo网站推广怎么做
  • 网站建设如何添加咨询西安计算机培训机构哪个最好