Back to project page SNET.
The source code is released under:
GNU Lesser General Public License
If you think the Android project SNET listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.snet.notepad; /*from w ww . java 2 s. c o m*/ import java.io.*; import java.util.Calendar; import com.snet.R; import com.snet.R.id; import com.snet.R.layout; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Environment; import android.preference.PreferenceManager; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.*; public class NoteEdition extends Activity { final String EXTRA_TITLE = "TitreNoteEdition"; final String EXTRA_NOTE = "NoteEdition"; final String EXTRA_EDITION = "edition"; final String EXTRA_ID = "id"; boolean edit = false; int id = 0; SharedPreferences pref; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); pref = PreferenceManager.getDefaultSharedPreferences(this); setContentView(R.layout.activity_noteedition); EditText titre = (EditText) findViewById(R.id.TitreNoteEdition); EditText note = (EditText) findViewById(R.id.NoteEdition); Intent intent = getIntent(); if (intent != null) { titre.setText(intent.getStringExtra(EXTRA_TITLE)); note.setText(intent.getStringExtra(EXTRA_NOTE)); edit = intent.getBooleanExtra(EXTRA_EDITION,false); id = intent.getIntExtra(EXTRA_ID,0); } //note.setTextSize(Integer.parseInt(pref.getString("pref_sizeNote", "16"))); note.setTextSize(Integer.parseInt(pref.getString("pref_sizeNote", "16"))); //Toast.makeText(this, edit + "", Toast.LENGTH_LONG).show(); //final Button button = (Button) findViewById(R.id.ButtonSave); /* button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //save(); } });*/ } public void popup(boolean r) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Sauvergarde"); if(r) { alertDialog.setMessage("Sauvegarde russi"); } else { alertDialog.setMessage("chec de la sauvegarde "); } alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // TODO Add your code for the button here. } }); // Set the Icon for the Dialog //alertDialog.setIcon(R.drawable.icon); alertDialog.show(); // see http://androidsnippets.com/simple-alert-dialog-popup-with-title-message-icon-and-button } public void save(View v) { EditText titreElt = (EditText)findViewById(R.id.TitreNoteEdition); String titre = titreElt.getText().toString(); EditText note = (EditText)findViewById(R.id.NoteEdition); String contenu = note.getText().toString(); NotesBDD noteBdd = new NotesBDD(this); Note n = new Note(titre, contenu); //Toast.makeText(this, id + n.getTitre() + n.getNote)Head(), Toast.LENGTH_LONG).show(); noteBdd.open(); if( edit == false){ noteBdd.insertNote(n); } else { noteBdd.updateNote(id,n); } Note noteFromBdd = noteBdd.getNoteWithTitre(n.getTitre()); if(noteFromBdd != null) { //On affiche les infos du livre dans un Toast //Toast.makeText(this, noteFromBdd.toString(), Toast.LENGTH_LONG).show(); if( edit == false){ Toast.makeText(this, "Sauvegarde russi", Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "Note mise jour", Toast.LENGTH_LONG).show(); } } else { Toast.makeText(this, "chec de la Sauvegarde", Toast.LENGTH_LONG).show(); } noteBdd.close(); /*Intent intent = new Intent(NoteEdition.this , NoteMain.class); NoteEdition.this.startActivity(intent);*/ this.finish(); } public void quit(View v) { /* Intent intent = new Intent(NoteEdition.this , NoteMain.class); NoteEdition.this.startActivity(intent);*/ this.finish(); } }