Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.faceattendancev20;
- import android.app.Activity;
- import android.database.Cursor;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.widget.TextView;
- import android.widget.Toast;
- public class AddStudentActivity extends Activity {
- private TextView TextViewStudentID;
- private TextView TextViewStudentName;
- private AttendanceDatabase mDatabase;
- private static final String TAG = "AddStudentActivity";
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_add_student);
- mDatabase = new AttendanceDatabase(AddStudentActivity.this);
- TextViewStudentID=(TextView)findViewById(R.id.editTextStudentID);
- TextViewStudentName=(TextView)findViewById(R.id.editTextStudentName);
- AttendanceDatabase database = new AttendanceDatabase(AddStudentActivity.this);
- TextView text =new TextView(database.getStudent()); //
- TextViewStudentID.setText(text);
- Bundle extras=getIntent().getExtras();
- if(extras!=null)
- {
- int Value=extras.getInt("stuID");
- if(Value>0)
- {
- Cursor cursor=database.getStudent(stuID);
- Log.d(TAG,"StuID");
- /*int id_to_update=Value;
- cursor.moveToFirst();
- String stuID=cursor.getString(cursor.getColumnIndex(AttendanceDatabase.COLUMN_STUDENT_ID));
- String stuName=cursor.getString(cursor.getColumnIndex(AttendanceDatabase.COLUMN_STUDENT_NAME));
- if(!cursor.isClosed())
- {
- cursor.close();
- }
- TextViewStudentID.setText((CharSequence)stuID);
- TextViewStudentID.setFocusable(false);
- TextViewStudentID.setClickable(false);
- TextViewStudentName.setText((CharSequence)stuName);
- TextViewStudentName.setFocusable(false);
- TextViewStudentName.setClickable(false);*/
- }
- }
- }
- @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_add_student, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- //noinspection SimplifiableIfStatement
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- }
- //from AttendanceDatabase.java
- public Cursor getStudent(int stuID)
- {
- return mDatabase.rawQuery("select * from student where stuID = " + stuID, null);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement