Android Open Source - HandyNotes Edit Note






From Project

Back to project page HandyNotes.

License

The source code is released under:

GNU General Public License

If you think the Android project HandyNotes listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.tapi.handynotes;
/*  www .  jav  a 2 s.  co  m*/
import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class EditNote extends Activity {
  private Integer widgetId;
  private EditText editText;
  private NotesDbAdapter db;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState);
        
        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        if (extras != null) {
            widgetId = extras.getInt(
                    AppWidgetManager.EXTRA_APPWIDGET_ID, 
                    AppWidgetManager.INVALID_APPWIDGET_ID);
        }
     
    setContentView(R.layout.edit_note);

        editText = (EditText) findViewById(R.id.editNoteText);
        
      db = new NotesDbAdapter(this);

        db.open();
        String text = db.showNoteText(widgetId);
        
        editText.setText(text);
        db.close();
        
        Button button = (Button) findViewById(R.id.updateButton);
        button.setOnClickListener(new View.OnClickListener() {
      
      public void onClick(View v) {
        saveNote();
        updateWidget();        
      }
    });
  
  }
  
  private void saveNote() {
    db.open();
    db.updateNote(widgetId, editText.getText().toString());
    db.close();
  }
  
  private void updateWidget() {
    Intent intent = new Intent(this, HandyNotes.class);
    intent.setAction("android.appwidget.action.APPWIDGET_UPDATE");
    
    int[] ids = {widgetId};
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
    sendBroadcast(intent);

    finish();
  }
}




Java Source Code List

net.tapi.handynotes.EditNote.java
net.tapi.handynotes.HandyNotes11.java
net.tapi.handynotes.HandyNotes22.java
net.tapi.handynotes.HandyNotes33.java
net.tapi.handynotes.HandyNotes41.java
net.tapi.handynotes.HandyNotes42.java
net.tapi.handynotes.HandyNotes44.java
net.tapi.handynotes.HandyNotes.java
net.tapi.handynotes.NewNote.java
net.tapi.handynotes.NotesDbAdapter.java