Advertisement
joshua93

AddStudentActivity.java

Dec 19th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.09 KB | None | 0 0
  1. package com.example.faceattendancev20;
  2.  
  3. import android.app.Activity;
  4. import android.database.Cursor;
  5. import android.os.Bundle;
  6. import android.util.Log;
  7. import android.view.Menu;
  8. import android.view.MenuItem;
  9. import android.widget.TextView;
  10. import android.widget.Toast;
  11.  
  12.  
  13. public class AddStudentActivity extends Activity {
  14.  
  15.     private TextView TextViewStudentID;
  16.     private TextView TextViewStudentName;
  17.     private AttendanceDatabase mDatabase;
  18.  
  19.     private static final String TAG = "AddStudentActivity";
  20.  
  21.     @Override
  22.     protected void onCreate(Bundle savedInstanceState) {
  23.         super.onCreate(savedInstanceState);
  24.         setContentView(R.layout.activity_add_student);
  25.  
  26.         mDatabase = new AttendanceDatabase(AddStudentActivity.this);
  27.         TextViewStudentID=(TextView)findViewById(R.id.editTextStudentID);
  28.         TextViewStudentName=(TextView)findViewById(R.id.editTextStudentName);
  29.  
  30.         AttendanceDatabase database = new AttendanceDatabase(AddStudentActivity.this);
  31.  
  32.         TextView text =new TextView(database.getStudent()); //
  33.  
  34.         TextViewStudentID.setText(text);
  35.  
  36.         Bundle extras=getIntent().getExtras();
  37.         if(extras!=null)
  38.         {
  39.             int Value=extras.getInt("stuID");
  40.             if(Value>0)
  41.             {
  42.  
  43.  
  44.                 Cursor cursor=database.getStudent(stuID);
  45.                 Log.d(TAG,"StuID");
  46.                 /*int id_to_update=Value;
  47.                 cursor.moveToFirst();
  48.                 String stuID=cursor.getString(cursor.getColumnIndex(AttendanceDatabase.COLUMN_STUDENT_ID));
  49.                 String stuName=cursor.getString(cursor.getColumnIndex(AttendanceDatabase.COLUMN_STUDENT_NAME));
  50.  
  51.                 if(!cursor.isClosed())
  52.                 {
  53.                     cursor.close();
  54.                 }
  55.                 TextViewStudentID.setText((CharSequence)stuID);
  56.                 TextViewStudentID.setFocusable(false);
  57.                 TextViewStudentID.setClickable(false);
  58.  
  59.                 TextViewStudentName.setText((CharSequence)stuName);
  60.                 TextViewStudentName.setFocusable(false);
  61.                 TextViewStudentName.setClickable(false);*/
  62.             }
  63.         }
  64.  
  65.  
  66.     }
  67.  
  68.  
  69.     @Override
  70.     public boolean onCreateOptionsMenu(Menu menu) {
  71.         // Inflate the menu; this adds items to the action bar if it is present.
  72.         getMenuInflater().inflate(R.menu.menu_add_student, menu);
  73.         return true;
  74.     }
  75.  
  76.     @Override
  77.     public boolean onOptionsItemSelected(MenuItem item) {
  78.         // Handle action bar item clicks here. The action bar will
  79.         // automatically handle clicks on the Home/Up button, so long
  80.         // as you specify a parent activity in AndroidManifest.xml.
  81.         int id = item.getItemId();
  82.  
  83.         //noinspection SimplifiableIfStatement
  84.         if (id == R.id.action_settings) {
  85.             return true;
  86.         }
  87.  
  88.         return super.onOptionsItemSelected(item);
  89.     }
  90. }
  91.  
  92. //from AttendanceDatabase.java
  93.  
  94.     public Cursor getStudent(int stuID)
  95.     {
  96.         return mDatabase.rawQuery("select * from student where stuID = " + stuID, null);
  97.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement