deltaaah
- Forum posts: 1
Mar 22, 2013, 1:18:20 AM via Website
Mar 22, 2013 1:18:20 AM via Website
Hi everyone, first time poster.
I'm hit a little snag with the first app I've built.
It's just the tutorial app off the Android Developer's page.
I'd post the link but it won't let me.
Here's my problem, I wrote the code out with 2 activities all linked together and such so that there is no error in Eclipse.
I'm debugging onto my Motorola Droid 2 and after I click the "Send" button it does not go to the next activity.
I've checked my code and all seems good, Perhaps there is something that I missed that you all might be able to clear up for me.
Thank you for reading and I look forward to your responses
( d |
This is my "DisplayMessageActivity.java" code where I believe the problem may lie, although unbeknownst to me.
I'm hit a little snag with the first app I've built.
It's just the tutorial app off the Android Developer's page.
I'd post the link but it won't let me.
Here's my problem, I wrote the code out with 2 activities all linked together and such so that there is no error in Eclipse.
I'm debugging onto my Motorola Droid 2 and after I click the "Send" button it does not go to the next activity.
I've checked my code and all seems good, Perhaps there is something that I missed that you all might be able to clear up for me.
Thank you for reading and I look forward to your responses
( d |
This is my "DisplayMessageActivity.java" code where I believe the problem may lie, although unbeknownst to me.
1package com.example.myfirstapp;
2
3import android.annotation.SuppressLint;
4import android.annotation.TargetApi;
5import android.app.Activity;
6import android.content.Intent;
7import android.os.Build;
8import android.os.Bundle;
9import android.support.v4.app.NavUtils;
10import android.view.MenuItem;
11import android.widget.TextView;
12
13public class DisplayMessageActivity extends Activity {
14
15 @SuppressLint("NewApi")
16 @Override
17 protected void onCreate(Bundle savedInstanceState) {
18 super.onCreate(savedInstanceState);
19 setContentView(R.layout.activity_display_message);
20
21 // Get the message from the intent
22 Intent intent = getIntent();
23 String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
24
25 // Create the text view
26 TextView textView = new TextView(this);
27 textView.setTextSize(40);
28 textView.setText(message);
29
30 // Set the text view as the activity layout
31 setContentView(textView);
32
33 // Make sure we're running on Honeycomb or higher to use ActionBar APIs
34 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOM {
35 // Show the Up button in the action bar.
36 getActionBar().setDisplayHomeAsUpEnabled(true);
37 }
38 }
39
40
41 /**
42 * Set up the {@link android.app.ActionBar}, if the API is available.
43 */
44
45 @TargetApi(Build.VERSION_CODES.HONEYCOM
46 private void setupActionBar() {
47 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOM {
48 getActionBar().setDisplayHomeAsUpEnabled(true);
49 }
50 }
51
52
53 @Override
54 public boolean onOptionsItemSelected(MenuItem item) {
55 switch (item.getItemId()) {
56 case android.R.id.home:
57 // This ID represents the Home or Up button. In the case of this
58 // activity, the Up button is shown. Use NavUtils to allow users
59 // to navigate up one level in the application structure. For
60 // more details, see the Navigation pattern on Android Design:
61 //
62 //
63 //
64 NavUtils.navigateUpFromSameTask(this);
65 return true;
66 }
67 return super.onOptionsItemSelected(item);
68 }
69
70}
2
3import android.annotation.SuppressLint;
4import android.annotation.TargetApi;
5import android.app.Activity;
6import android.content.Intent;
7import android.os.Build;
8import android.os.Bundle;
9import android.support.v4.app.NavUtils;
10import android.view.MenuItem;
11import android.widget.TextView;
12
13public class DisplayMessageActivity extends Activity {
14
15 @SuppressLint("NewApi")
16 @Override
17 protected void onCreate(Bundle savedInstanceState) {
18 super.onCreate(savedInstanceState);
19 setContentView(R.layout.activity_display_message);
20
21 // Get the message from the intent
22 Intent intent = getIntent();
23 String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
24
25 // Create the text view
26 TextView textView = new TextView(this);
27 textView.setTextSize(40);
28 textView.setText(message);
29
30 // Set the text view as the activity layout
31 setContentView(textView);
32
33 // Make sure we're running on Honeycomb or higher to use ActionBar APIs
34 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOM {
35 // Show the Up button in the action bar.
36 getActionBar().setDisplayHomeAsUpEnabled(true);
37 }
38 }
39
40
41 /**
42 * Set up the {@link android.app.ActionBar}, if the API is available.
43 */
44
45 @TargetApi(Build.VERSION_CODES.HONEYCOM
46 private void setupActionBar() {
47 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOM {
48 getActionBar().setDisplayHomeAsUpEnabled(true);
49 }
50 }
51
52
53 @Override
54 public boolean onOptionsItemSelected(MenuItem item) {
55 switch (item.getItemId()) {
56 case android.R.id.home:
57 // This ID represents the Home or Up button. In the case of this
58 // activity, the Up button is shown. Use NavUtils to allow users
59 // to navigate up one level in the application structure. For
60 // more details, see the Navigation pattern on Android Design:
61 //
62 //
63 //
64 NavUtils.navigateUpFromSameTask(this);
65 return true;
66 }
67 return super.onOptionsItemSelected(item);
68 }
69
70}
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.