Advertisement
Guest User

Main class

a guest
Jan 13th, 2011
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.96 KB | None | 0 0
  1. package com.adamblanchard.remindme.com.adamblanchard;
  2.  
  3. import com.adamblanchard.remindme.R;
  4. import android.app.Activity;
  5. import android.app.AlertDialog;
  6. import android.app.Notification;
  7. import android.app.NotificationManager;
  8. import android.app.PendingIntent;
  9. import android.content.Context;
  10. import android.content.DialogInterface;
  11. import android.content.Intent;
  12. import android.os.Bundle;
  13. import android.view.KeyEvent;
  14. import android.view.Menu;
  15. import android.view.MenuInflater;
  16. import android.view.MenuItem;
  17. import android.view.View;
  18. import android.view.View.OnKeyListener;
  19. import android.widget.Button;
  20. import android.widget.EditText;
  21.  
  22.  
  23.  
  24. public class remindme extends Activity {
  25.  
  26.     public CharSequence note = "not changed";
  27.  
  28. int HELLO_ID = 1;
  29.  
  30.     /** Called when the activity is first created. */
  31.         @Override
  32.     public boolean onCreateOptionsMenu(Menu menu) {
  33.         MenuInflater inflater = getMenuInflater();
  34.         inflater.inflate(R.menu.menu, menu);
  35.         return true;
  36.  
  37.         }
  38.     @Override
  39.     public boolean onOptionsItemSelected(MenuItem item) {
  40.         switch (item.getItemId()) {
  41.             case R.id.exit: this.finish();
  42.                                 break;
  43.         }
  44.         return true; }
  45.  
  46.     @Override
  47.     public void onCreate(Bundle savedInstanceState) {
  48.         super.onCreate(savedInstanceState);
  49.         setContentView(R.layout.main);
  50.         setTitle("Remind Me!");
  51.        
  52.    
  53.         final EditText edittext = (EditText) findViewById(R.id.input);
  54.         final Button inputbtn = (Button) findViewById(R.id.button);
  55.  
  56. //Button Enter
  57.        
  58.         inputbtn.setOnClickListener(new View.OnClickListener() {
  59.          public void onClick(View v) {
  60.              note = edittext.getText().toString();
  61.              
  62.              
  63.              new AlertDialog.Builder(remindme.this)
  64.  
  65.              .setTitle("Set Notification?")
  66.  
  67.              .setMessage(null)
  68.  
  69.              .setPositiveButton("Yes",
  70.  
  71.              new DialogInterface.OnClickListener() {
  72.  
  73.              public void onClick(DialogInterface dialog,
  74.  
  75.              int which) {
  76.                  Note Note = new Note();
  77.   Note.callNotification();
  78.   edittext.setText("");
  79.              }})
  80.              
  81.             .setNeutralButton("NO",
  82.  
  83.              new DialogInterface.OnClickListener() {
  84.  
  85.              public void onClick(DialogInterface dialog,
  86.  
  87.              int which) {
  88.                
  89.              }})
  90.              
  91.              .show();
  92.  
  93.          }
  94.          
  95.      }
  96.      );
  97.      
  98.      
  99. //Keyboard Enter    
  100.      
  101.         edittext.setOnKeyListener(new OnKeyListener() {
  102.             public boolean onKey(View v, int keyCode, KeyEvent event) {
  103.                 // If the event is a key-down event on the "enter" button
  104.                 if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
  105.                     (keyCode == KeyEvent.KEYCODE_ENTER)) {
  106.                   // Perform action on key press
  107.                    
  108.                     note = edittext.getText().toString();
  109.                    
  110.                     new AlertDialog.Builder(remindme.this)
  111.  
  112.                     .setTitle("Set Notification?")
  113.  
  114.                     .setMessage(null)
  115.  
  116.                     .setPositiveButton("Yes",
  117.  
  118.                     new DialogInterface.OnClickListener() {
  119.  
  120.                     public void onClick(DialogInterface dialog,
  121.  
  122.                     int which) {
  123.                         Note Note = new Note();
  124.          Note.callNotification();
  125.          edittext.setText("");
  126.                     }})
  127.                    
  128.                    .setNeutralButton("NO",
  129.  
  130.                     new DialogInterface.OnClickListener() {
  131.  
  132.                     public void onClick(DialogInterface dialog,
  133.  
  134.                     int which) {
  135.                        
  136.                     }})
  137.                    
  138.                     .show();
  139.                  
  140.                  
  141.                   return true;
  142.                 }
  143.                 return false;
  144.             }
  145.         });
  146.    
  147.    
  148.     }
  149.    
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement