一.新建工程

二.新建XML代码

新建一个Button
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按键"
android:id="@+id/button"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" /> 新建一个界面:
<TextView
android:id="@+id/title3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="物联网社团出品"
android:textColor="#eecc11"
android:textSize="40sp" />

三.新建java工程

private Button btn1;
@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1=(Button)findViewById(R.id.btn1);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,newp.class);
startActivity(i);
}
});
}

四.新建Java类

package com.jmk.button;

import android.os.Bundle;

public class newp extends MainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_page); }
}

五.注册表中

<activity android:name="newp"></activity>

Android onclick监听事件打开新界面的更多相关文章

  1. [Android Pro] 监听WIFI 打开广播

    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-perm ...

  2. Android输入法 监听事件

    登录界面有一个输入用户名和密码的编辑框: private EditText et_userName;// 账户 private EditText et_password;// 密码 布局文件如下: & ...

  3. android editText 监听事件

    在软键盘中注意 在监听的 edittext中 使用android:imeOptions属性的时候,一定要对EditText设置 android:inputType 或者 设置 android:sing ...

  4. [Android Pro] 监听Blutooth打开广播

    <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission a ...

  5. android典型监听事件实

    public class MainActivity extends Activity { int counter; Button add, sub; TextView display; @Overri ...

  6. android EditText监听事件及参数详解

    editText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence ...

  7. eas中删除原来的监听事件添加新的监听事件

    kdtEntrys.removeKDTEditListener(kdtEntrys.getListeners(KDTEditListener.class)[0]);  kdtEntrys.addKDT ...

  8. xamarin android如何监听单击事件

    在xamarin android单击事件是最基础的事情,看过菜鸟上的android教程时,java写的都是监听事件,为一个按钮,单选按钮.多选按钮的单击事件有三种,前面两种用的非常普遍,也很简易,我这 ...

  9. Android如何监听蓝牙耳机的按键事件

    写在前面: 直接想要代码很简单,你直接把滚动条拉到最底端就可以看到.如果想要十分地了解为什么,那就按照我规划的一步一步来理解.以下测试环境以手头上有的「Bluedio + 红米手机」. 1.蓝牙耳机的 ...

随机推荐

  1. Best Time to Buy and Sell Stock系列

    I题 Say you have an array for which the ith element is the price of a given stock on day i. If you we ...

  2. 如何使用CocoaPods

    如何使用CocoaPods 1.进入主目录下 cd /Users/HYYT/Desktop/支付功能/微信支付宝集成/支付宝微信支付集成 2.建立Podfile(配置文件) 2.1  输入:vim P ...

  3. hibernate的反转引擎生成两个实体类的问题

    在使用myeclipse中自带的hibernate 进行jsp开发时候遇到了这个问题.使用hibernate的反转引擎从数据库生成生成实体类,一个表生成了两个类,xx.java和xxId.java . ...

  4. 解决tomcat debug 调试时间过长的问题

    做java web很早就碰到一个问题,eclipse 的调试有时候忽然启动时间奇慢 ,但是正常启动速度没问题,其他项目也完全正常 后来想想也不影响项目运行,也没太在意 不过今天又碰到这问题了,而且启动 ...

  5. Centos7多网卡绑定操作,通过nmcli命令操作。

    运行 ip link 命令查看系统中可用的接口1.创建bond网卡nmcli con add type team con-name team0 ifname team0 config '{" ...

  6. 本地yum服务搭建

    1.准备linux ISO系统镜像文件 (例如:rhel-server-5.5-i386-dvd.iso) 2.linux虚拟机(centos 7  192.168.50.24 ),启动sshd服务 ...

  7. NodeJS+express+mogondb学习笔记01

    0.准备工作  安装nodejs环境  官网地址:https://nodejs.org/en/  下载好了 直接一路安装 也没有什么可以说的 不得不说nodejs对于新手上手还是很友好的,再加上现在n ...

  8. 动画制作 手机APP制作以及响应式的实现

    babber 宽度:浏览器的100% 原则上:高度-=图片高度 banner img 宽度:图片的实际宽度 高度:充满父容器 使用定位:让图片在父容器中绝对居中.     <!DOCTYPE h ...

  9. PMD教程

    1.单词 violations outline:错误大纲2.错误级别 红色 很高的错误 橙色 错误 黄色 很高的警告 绿色 警告 蓝色 输出信息3.提示 Avoid excessively long ...

  10. GTK简单了解记录

    GTK+http://zh.wikipedia.org/wiki/GTK%2B#.E5.9B.BE.E5.BD.A2.E6.97.A0.E5.85.B3.E4.BB.A3.E7.A0.81 GTK+最 ...