Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.adamblanchard.remindme.com.adamblanchard;
- import com.adamblanchard.remindme.R;
- import android.app.Activity;
- import android.app.AlertDialog;
- import android.app.Notification;
- import android.app.NotificationManager;
- import android.app.PendingIntent;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.KeyEvent;
- import android.view.Menu;
- import android.view.MenuInflater;
- import android.view.MenuItem;
- import android.view.View;
- import android.view.View.OnKeyListener;
- import android.widget.Button;
- import android.widget.EditText;
- public class remindme extends Activity {
- public CharSequence note = "not changed";
- int HELLO_ID = 1;
- /** Called when the activity is first created. */
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.menu, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.exit: this.finish();
- break;
- }
- return true; }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- setTitle("Remind Me!");
- final EditText edittext = (EditText) findViewById(R.id.input);
- final Button inputbtn = (Button) findViewById(R.id.button);
- //Button Enter
- inputbtn.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- note = edittext.getText().toString();
- new AlertDialog.Builder(remindme.this)
- .setTitle("Set Notification?")
- .setMessage(null)
- .setPositiveButton("Yes",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int which) {
- Note Note = new Note();
- Note.callNotification();
- edittext.setText("");
- }})
- .setNeutralButton("NO",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int which) {
- }})
- .show();
- }
- }
- );
- //Keyboard Enter
- edittext.setOnKeyListener(new OnKeyListener() {
- public boolean onKey(View v, int keyCode, KeyEvent event) {
- // If the event is a key-down event on the "enter" button
- if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
- (keyCode == KeyEvent.KEYCODE_ENTER)) {
- // Perform action on key press
- note = edittext.getText().toString();
- new AlertDialog.Builder(remindme.this)
- .setTitle("Set Notification?")
- .setMessage(null)
- .setPositiveButton("Yes",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int which) {
- Note Note = new Note();
- Note.callNotification();
- edittext.setText("");
- }})
- .setNeutralButton("NO",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int which) {
- }})
- .show();
- return true;
- }
- return false;
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement