Android Open Source - ExpertAndroid Create A Word Activity

From Project

Back to project page ExpertAndroid.


The source code is released under:

MIT License

If you think the Android project ExpertAndroid 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 com.androidbook.parse;
//from   w  ww.j a  v  a2s  . co m
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.parse.ParseException;
import com.parse.SaveCallback;

public class CreateAWordActivity 
extends FormActivity 
  EditText word;
  EditText meaning;
  public CreateAWordActivity() 

  public void onCreate(Bundle savedInstanceState) {

  protected void initializeFormFields() 
    word = (EditText)findViewById(;
    meaning = (EditText)findViewById(;
    addValidator(new Field(word));
    //meaning is optional

  private String getWord()
    return word.getText().toString();
  private String getMeaning()
    String m = meaning.getText().toString();
    if (validString(m) == true)
      return m;
    return "";
  public void createWord(View v){
    if (validateForm() == false) {
    //form is valid
    String sWord = getWord();
    String sMeaning = getMeaning();
    Word w = new Word(sWord, sMeaning);
    turnOnProgressDialog("Saving Word", "We will be right back");
    w.po.saveInBackground(new SaveCallback() {
      public void done(ParseException e) {
        if (e == null)  {
          //no exception
        else  {
  private void wordSaveFailed(ParseException e)
    String error = e.getMessage();
    alert("Saving word failed", error);
  private void wordSavedSuccessfully()
    //Don't finish it as back button is valid

Java Source Code List