Advertisement
Guest User

DisplayMessageActivity.java

a guest
Jan 21st, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. package com.mycompany.myfirstapp;
  2.  
  3. import android.content.Intent;
  4. import android.support.v7.app.ActionBarActivity;
  5. import android.os.Bundle;
  6. import android.view.Menu;
  7. import android.view.MenuItem;
  8. import android.widget.TextView;
  9.  
  10.  
  11. public class DisplayMessageActivity extends ActionBarActivity {
  12.  
  13. @Override
  14. public void onCreate(Bundle savedInstanceState) {
  15. super.onCreate(savedInstanceState);
  16.  
  17. // Get the message from the intent
  18. Intent intent = getIntent();
  19. String message = intent.getStringExtra(MyActivity.EXTRA_MESSAGE);
  20.  
  21. // Create the text view
  22. TextView textView = new TextView(this);
  23. textView.setTextSize(40);
  24. textView.setText(message);
  25.  
  26. // Set the text view as the activity layout
  27. setContentView(textView);
  28. }
  29.  
  30. @Override
  31. public boolean onOptionsItemSelected(MenuItem item) {
  32. // Handle action bar item clicks here. The action bar will
  33. // automatically handle clicks on the Home/Up button, so long
  34. // as you specify a parent activity in AndroidManifest.xml.
  35. int id = item.getItemId();
  36.  
  37. //noinspection SimplifiableIfStatement
  38. if (id == R.id.action_settings) {
  39. return true;
  40. }
  41.  
  42. return super.onOptionsItemSelected(item);
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement