Back to project page NexusData.
The source code is released under:
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCT...
If you think the Android project NexusData 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 org.example.todo; // w w w .j ava 2 s . c om import android.app.Activity; import android.os.Bundle; import android.text.TextUtils; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.widget.EditText; import ch.qos.logback.classic.Logger; import com.github.dkharrat.nexusdata.core.ObjectContext; public class NewTaskActivity extends Activity { EditText titleText, notesText; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.new_task); titleText = (EditText)findViewById(R.id.title); notesText = (EditText)findViewById(R.id.notes); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.form_actionbar, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { boolean result = super.onOptionsItemSelected(item); if (validateForm()) { saveTask(); result = true; } return result; } private boolean validateForm() { return !TextUtils.isEmpty(titleText.getText()); } private void saveTask() { String title = titleText.getText().toString(); String notes = notesText.getText().toString(); ObjectContext ctx = TodoApp.getMainObjectContext(); Task newTask = ctx.newObject(Task.class); newTask.setTitle(title); newTask.setNotes(notes); ctx.save(); finish(); } }