X-Git-Url: https://git.ao2.it/android/MyFirstApp.git/blobdiff_plain/9d1588880e2673b353da9dbb032da7629a4f84d9..feb1f9f6ccbec1094aebb4831e8760d11eda6beb:/src/com/example/myfirstapp/DisplayMessageActivity.java diff --git a/src/com/example/myfirstapp/DisplayMessageActivity.java b/src/com/example/myfirstapp/DisplayMessageActivity.java new file mode 100644 index 0000000..6f25ee0 --- /dev/null +++ b/src/com/example/myfirstapp/DisplayMessageActivity.java @@ -0,0 +1,47 @@ +package com.example.myfirstapp; + +import android.annotation.SuppressLint; +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); + // Get the message from the intent + Intent intent = getIntent(); + String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE); + + // Create the text view + TextView textView = new TextView(this); + textView.setTextSize(40); + textView.setText(message); + + // Set the text view as the activity layout + setContentView(textView); + + + // Make sure we're running on Honeycomb or higher to use ActionBar APIs + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + // Show the Up button in the action bar. + getActionBar().setDisplayHomeAsUpEnabled(true); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + NavUtils.navigateUpFromSameTask(this); + return true; + } + return super.onOptionsItemSelected(item); + } +}