Android Open Source - android-final-exam-stuff Add Student Activity






From Project

Back to project page android-final-exam-stuff.

License

The source code is released under:

Apache License

If you think the Android project android-final-exam-stuff 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 tr.edu.iyte.ceng389.finalexamstuff;
//from  ww  w.j a  v  a 2 s  .  c om
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class AddStudentActivity extends Activity
{
  private StudentDetailsFragment detailsFragment;
  
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add);
    
    detailsFragment = (StudentDetailsFragment) getFragmentManager().findFragmentById(R.id.fragment_studentDetails);
  }
  
  @Override
  public boolean onPrepareOptionsMenu(Menu menu)
  {
    getMenuInflater().inflate(R.menu.save_menu, menu);
    
    return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item)
  {
    switch(item.getItemId())
    {
      case R.id.save_student:
        if(detailsFragment != null)
        {
          Student student = detailsFragment.getStudent();
          
          if(student != null)
          {
            // Save to database
            Uri newStudent = getContentResolver().insert(StudentProvider.CONTENT_URI, StudentProvider.studentToContentValues(student));
            
            finish();
            
            return true;
          }
        }
    }
    
    return false;
  }
}




Java Source Code List

tr.edu.iyte.ceng389.finalexamstuff.AddStudentActivity.java
tr.edu.iyte.ceng389.finalexamstuff.MainActivity.java
tr.edu.iyte.ceng389.finalexamstuff.StudentAdapter.java
tr.edu.iyte.ceng389.finalexamstuff.StudentDetailsActivity.java
tr.edu.iyte.ceng389.finalexamstuff.StudentDetailsFragment.java
tr.edu.iyte.ceng389.finalexamstuff.StudentListFragment.java
tr.edu.iyte.ceng389.finalexamstuff.StudentProvider.java
tr.edu.iyte.ceng389.finalexamstuff.Student.java