栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

不幸的是,应用程序已停止android模拟器genymotion

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

不幸的是,应用程序已停止android模拟器genymotion

您在第38行获得了NPE,即:

add.setonClickListener(new View.onClickListener()

所以

add
为null,并且因为您将按钮声明为:

add = (Button) findViewById(R.id.bt_add);

所以

bt_add
id在上不存在
activity_main
,我认为您发布的这个xml
fragment_main.xml
或其他任何内容。

当你定义你的主要布局

activity_main

setContentView(R.layout.activity_main);

因此您必须在其中具有以下ID

activity_main

1-

bt_add

2

bt_sub

3

textView1

因此,您必须具有

activity_main
以下代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" ><TextView    android:id="@+id/textView1"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:gravity="center"    android:text="ur total is 0"    android:textSize="40sp" />    <Button        android:id="@+id/bt_add"        android:layout_width="250dp"        android:layout_height="40dp"        android:layout_below="@+id/textView1"        android:layout_centerHorizontal="true"        android:layout_marginTop="20dp"        android:text="add one" />    <Button        android:id="@+id/bt_sub"        android:layout_width="250dp"        android:layout_height="40dp"        android:layout_alignLeft="@+id/bt_add"        android:layout_below="@+id/bt_add"        android:layout_marginTop="19dp"        android:text="sub one" />


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/497454.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号