java - Android Emulator Response:Unfortunately HelloWorld has stopped -
I'm following the following: I've created the default Hello World app, but when I try to run it load it Will not done! I decided to go to the next video and created a simple project called "Hello, world!" When a button is pressed, but when I run the project, I get this message on the emulator:
Unfortunately hello world is closed.
I've been trying several hours to find many threads, but no one lets me solve it, I'm using the latest ADT bundle (API 20) version 23. Here are two files:
Menactivity.java
package com ebook.helloworld; Import android App Import android.view.MenuItem; Import android.view.View; Import android.widget.TextView; Public classroom enhances main activity activity {@ Override Protected Zero (Bundled Saved Instance) {super.onCreate (savedInstanceState); SetContentView (R.layout.activity_main); } Public void onBtnTouch (see v) {TextView TV = (TextView) findViewById (R.id.textView1); Tv.setText ("Hello, World!"); } @ Override Public Boolean On Option Itam Select (menu item) {// Handle action bar item here clicks the action bar will automatically click on the Home / Up button, so long as you // in AndroidManifest.xml Specify basic activity. Int id = item.getItemId (); If (id == R.id.action_settings) {return true; } Return Super.Options item selected (item); }}
activity_main.xml
& lt; RelativeLayout xmlns: Android = "http://schemas.android.com/en/ apk / res / android" xmlns: tool = "http://schemas.android.com/tools" Android: layout_width = "match_parent" Android: layout_height = "Match_parent" Android: paddingBottom = "@ Dimen / activity_vertical_margin" Android: paddingLeft = "@ Dimen / activity_horizontal_margin" Android: paddingRight = "@ Dimen / activity_horizontal_margin" Android: paddingTop = "@ Dimen / activity_vertical_margin" tool: reference = "com. Ebook.helloworld.MainActivity "& gt; & Lt; Android: Layout = "@ + id / Button1" Android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_below = "@ + id / textView1" Android: layout_centerHorizontal = "true" Android: onClick = "OnBtnTouch "Android: Text =" Hi Hi "/> & Lt; Android: layout_height = "wrap_content" android: layout_alignParentTop = "true" android: layout_centerHorizontal = "true" android: layout_marginTop = "93dp" Android: TextAppearance: TextView: Android: layout_width = "wrap_content" android: id = "@ + id / textView1" = "? Android: attr / textAppearanceLarge" /> & Lt; / RelativeLayout & gt;
Where did you set the button? You should put it in the on crate:
button button = 1 (button) this.findViewById (R.id.button1);
And then you can:
button1.setOnClickListener (New OnClickListener () {@Override Public Zero onClick (see v) {// You What do we want to do ...}});
Comments
Post a Comment