为了账号安全,请及时绑定邮箱和手机立即绑定

点击按钮时,程序自动关闭,显示错误

点击按钮时,程序自动关闭,显示错误

牧羊人nacy 2019-04-25 15:19:34
在Android中设置一个按钮,点击按钮跳转至另一个页面。编写完成后,运行不了,点击该按钮,程序自动关闭。求求各位大神帮我看看哪里有问题。1.这是main.java.里的相关代码 @Override             public void onClick(View arg0) {                 Intent intent=new Intent(MainActivity.this,TwoActivity.class);                 startActivity(intent);             }2.这是two.Java里的代码 package com.jikexueyuan.testqrcode; import android.app.Activity; import android.os.Bundle; public class TwoActivity extends Activity {  @Override protected void onCreate(Bundle saveInstanceState){      super.onCreate(saveInstanceState);      setContentView(R.layout.two);  } }3.这是main.xml的代码 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:id="@+id/container"     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="match_parent"     tools:context="com.jikexueyuan.testqrcode.MainActivity"     tools:ignore="MergeRootFrame" > <Button         android:id="@+id/gen"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_marginTop="36dp"        android:text="生成二维码"        />     </LinearLayout>4.这是two.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" >     <Button         android:id="@+id/button1"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="名片" />     <Button         android:id="@+id/button2"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="短信" /></LinearLayout>
查看完整描述

4 回答

?
吃鸡游戏

TA贡献1829条经验 获得超7个赞

检查activity在AndroidManifest.xml中注册了没


查看完整回答
反对 回复 2019-05-14
?
暮色呼如

TA贡献1853条经验 获得超9个赞

图片上传入口:

图片说明

android 闪退必定会有闪退日志,直接看 Caused by 后面错误log,应该就可以解决问题了


查看完整回答
反对 回复 2019-05-14
?
一只斗牛犬

TA贡献1784条经验 获得超2个赞

查看错误报表,,,,针对修改


查看完整回答
反对 回复 2019-05-14
  • 4 回答
  • 0 关注
  • 458 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信