Advertisement
Guest User

MyActivity.java

a guest
Jan 21st, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 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.view.View;
  9. import android.widget.EditText;
  10.  
  11.  
  12. public class MyActivity extends ActionBarActivity {
  13.  
  14. public final static String EXTRA_MESSAGE = "com.mycompany.myfirstapp.MESSAGE";
  15.  
  16. /** Called when the user clicks the Send button */
  17. public void sendMessage(View view) {
  18. Intent intent = new Intent(this, DisplayMessageActivity.class);
  19. EditText editText = (EditText) findViewById(R.id.edit_message);
  20. String message = editText.getText().toString();
  21. intent.putExtra(EXTRA_MESSAGE, message);
  22. startActivity(intent);
  23. }
  24.  
  25. @Override
  26. protected void onCreate(Bundle savedInstanceState) {
  27. super.onCreate(savedInstanceState);
  28. setContentView(R.layout.activity_my);
  29. }
  30.  
  31.  
  32. @Override
  33. public boolean onCreateOptionsMenu(Menu menu) {
  34. // Inflate the menu; this adds items to the action bar if it is present.
  35. getMenuInflater().inflate(R.menu.menu_my, menu);
  36. return true;
  37. }
  38.  
  39. @Override
  40. public boolean onOptionsItemSelected(MenuItem item) {
  41. // Handle action bar item clicks here. The action bar will
  42. // automatically handle clicks on the Home/Up button, so long
  43. // as you specify a parent activity in AndroidManifest.xml.
  44. int id = item.getItemId();
  45.  
  46. //noinspection SimplifiableIfStatement
  47. if (id == R.id.action_settings) {
  48. return true;
  49. }
  50.  
  51. return super.onOptionsItemSelected(item);
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement