Wednesday, March 26, 2014

android found in the test program ends


I follow the tutorial android official website made the first android app, but when you do the test found on my nexus4 phone program after completing the first activity can not enter the second activity. We want to help look great God, thank you!
 
package com.example.myfirstapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
}


@ Override
public boolean onCreateOptionsMenu (Menu menu) {
/ / Inflate the menu; this adds items to the action bar if it is present
.getMenuInflater () inflate (R.menu.main, menu);.
return true;
}

public void sendMessge (View view) {
Intent intent = new Intent (this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById (R.id.edit_message);
String message = editText.getText () toString ();.
intent.putExtra (EXTRA_MESSAGE, message);
startActivity (intent);
}
}


 package com.example.myfirstapp; 

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import android.widget.TextView;

public class DisplayMessageActivity extends Activity {
@ SuppressLint ("NewApi")
@ Override


protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_display_message);
/ / Show the Up button in the action bar.
setupActionBar ();
if (Build.VERSION.SDK_INT> = Build.VERSION_CODES.HONEYCOMB) {
getActionBar () setDisplayHomeAsUpEnabled (true);.
}
Intent intent = getIntent ();
String message = intent.getStringExtra (MainActivity.EXTRA_MESSAGE);

TextView textView = new TextView (this);
textView.setTextSize (40);
textView.setText (message);

setContentView (textView);
}

/ **
* Set up the {@ link android.app.ActionBar}, if the API is available.
* /
@ TargetApi (Build.VERSION_CODES.HONEYCOMB)
private void setupActionBar () {
if (Build.VERSION.SDK_INT> = Build.VERSION_CODES.HONEYCOMB) {
getActionBar () setDisplayHomeAsUpEnabled (true);.
}
}



@ Override
public boolean onOptionsItemSelected (MenuItem item) {
switch (item.getItemId ()) {
case android.R.id.home:
/ / This ID represents the Home or Up button. In the case of this
/ / Activity, the Up button is shown. Use NavUtils to allow users
/ / To navigate up one level in the application structure. For
/ / More details, see the Navigation pattern on Android Design:
/ /
/ / Http://developer.android.com/design/patterns/navigation.html # up-vs-back
/ /
NavUtils.navigateUpFromSameTask (this);
return true;
}
return super.onOptionsItemSelected (item);
}

}


 xmlns: tools = "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"
tools: context = "DisplayMessageActivity.">

android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
/>




 

xmlns: tools = "http://schemas.android.com/tools"
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: orientation = "horizontal">

android: layout_weight = "1"
android: layout_width = "0dp"
android: layout_height = "wrap_content"
android: hint = "@ string / edit_message" />


 



My First App
Enter a message
Send
Settings
MainActivity
My Message



<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
DisplayMessageActivity this you registered yet inside the AndroidManaifeset.xml
Reply:
cited a floor guoyoulei520 reply:
DisplayMessageActivity that you registered yet in AndroidManaifeset.xml inside

This has been registered, it is automatically added to the eclipse. Can not run android version and what relationship, the tutorial that their code is running on android4.0, I this is 4.3
 
android: name = "com.example.myfirstapp.DisplayMessageActivity"
android: label = "@ string / title_activity_display_message"
android: parentActivityName = "com.example.myfirstapp.MainActivity">
android: name = "android.support.PARENT_ACTIVITY"
android: value = "com.example.myfirstapp.MainActivity" />


Reply:
reference to the second floor singlett reply:
Quote: references to a floor guoyoulei520 reply:

DisplayMessageActivity this inside you AndroidManaifeset.xml registered yet

This has been registered, it is automatically added to the eclipse. Can not run android version and what relationship, the tutorial that their code is running on android4.0, I this is 4.3
 
android: name = "com.example.myfirstapp.DisplayMessageActivity"
android: label = "@ string / title_activity_display_message"
android: parentActivityName = "com.example.myfirstapp.MainActivity">
android: name = "android.support.PARENT_ACTIVITY"
android: value = "com.example.myfirstapp.MainActivity" />

It does not matter what misstatements
Reply:
reference to the third floor guoyoulei520 reply:
Quote: references to the second floor singlett reply:

Quote: references to a floor guoyoulei520 reply:

DisplayMessageActivity this inside you AndroidManaifeset.xml registered yet

This has been registered, it is automatically added to the eclipse. Can not run android version and what relationship, the tutorial that their code is running on android4.0, I this is 4.3
 
android: name = "com.example.myfirstapp.DisplayMessageActivity"
android: label = "@ string / title_activity_display_message"
android: parentActivityName = "com.example.myfirstapp.MainActivity">
android: name = "android.support.PARENT_ACTIVITY"
android: value = "com.example.myfirstapp.MainActivity" />

It does not matter what misstatements

Control panel shows that, without being given
[2013-10-11 01:48:45 - MyFirstApp] ------------------------------
[2013-10-11 01:48:45 - MyFirstApp]! Android Launch
[2013-10-11 01:48:45 - MyFirstApp] adb is running normally
.[2013-10-11 01:48:45 - MyFirstApp] Performing com.example.myfirstapp.MainActivity activity launch
[2013-10-11 01:48:45 - MyFirstApp] Automatic Target Mode: using device '047faa901cd02ed8 '
[2013-10-11 01:48:45 - MyFirstApp] Uploading MyFirstApp.apk onto device '047faa901cd02ed8 '
[2013-10-11 01:48:45 - MyFirstApp] Installing MyFirstApp.apk ...
[2013-10-11 01:48:48 - MyFirstApp]! Success
[2013-10-11 01:48:48 - MyFirstApp] Starting activity com.example.myfirstapp.MainActivity on device 047faa901cd02ed8
[2013-10-11 01:48:48 - MyFirstApp] ActivityManager: Starting: Intent {act = android.intent.action.MAIN cat = [android.intent.category.LAUNCHER] cmp = com.example.myfirstapp / .MainActivity }
[2013-10-11 02:59:25 - MyFirstApp] ------------------------------
[2013-10-11 02:59:25 - MyFirstApp]! Android Launch
[2013-10-11 02:59:25 - MyFirstApp] adb is running normally
.[2013-10-11 02:59:25 - MyFirstApp] Performing com.example.myfirstapp.MainActivity activity launch
[2013-10-11 02:59:25 - MyFirstApp] Automatic Target Mode: using device '047faa901cd02ed8 '
[2013-10-11 02:59:25 - MyFirstApp] Uploading MyFirstApp.apk onto device '047faa901cd02ed8 '
[2013-10-11 02:59:25 - MyFirstApp] Installing MyFirstApp.apk ...
[2013-10-11 02:59:27 - MyFirstApp]! Success
[2013-10-11 02:59:27 - MyFirstApp] Starting activity com.example.myfirstapp.MainActivity on device 047faa901cd02ed8
[2013-10-11 02:59:28 - MyFirstApp] ActivityManager: Starting: Intent {act = android.intent.action.MAIN cat = [android.intent.category.LAUNCHER] cmp = com.example.myfirstapp / .MainActivity }

Reply:
This is Consle output without error.
Fat LogCat up to look at.
Reply:
setContentView (textView); Here it is dead.
Reply:
The setupActionBar (); commented try again.
Reply:
sendMessge (View v) did not call inside onCreate
Reply:
reference to the 8th floor xp460757952 reply:
sendMessge (View v) did not call
In onCreate inside

Yes, because wrong, it should be sendMessage (View view), now changed over, no problem. Thank you

No comments:

Post a Comment