Back to project page KnowledgeBase.
The source code is released under:
MIT License
If you think the Android project KnowledgeBase 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.martin.knowledgebase; /*from w ww . j a v a 2 s . c om*/ import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.EditText; import android.widget.RelativeLayout; import java.util.ArrayList; public class EditActivity extends Activity { private EditText mTitle, mText; private Snackbar mSnackbar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit); mTitle = (EditText) findViewById(R.id.etTitle); mText = (EditText) findViewById(R.id.etText); mSnackbar = new Snackbar((RelativeLayout) findViewById(R.id.snackbar), "Title and/or text missing", this); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_edit, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_done) { if (!mTitle.getText().toString().contentEquals("") && !mText.getText().toString().contentEquals("")) { ArrayList<Entry> entries = PlainStorage.getInstance().getmEntries(); entries.add(new Entry(mTitle.getText().toString(), mText.getText().toString(), Util.getCurrentDate())); PlainStorage.getInstance().setmEntries(entries); finish(); } else { mSnackbar.show(); } return true; } return super.onOptionsItemSelected(item); } }