6. // Inflate the menu; this adds items to the action bar if it
is present.
getMenuInflater().inflate(R.menu.menu_admin_home, 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);
}
@Override
public void onClick(View v) {
int id=v.getId();
if(id==R.id.faulty)
{
Intent fa=new
Intent(AdminHomeActivity.this,FacultyList.class);
startActivity(fa);
}
else if(id==R.id.student)
{
Intent st=new
Intent(AdminHomeActivity.this,StudentList.class);
startActivity(st);
}
}
}
AdminLoin.java
package com.gpslocation.attendanceandmarkssystem;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
7. import android.widget.EditText;
import android.widget.Toast;
public class Adminlogin extends Activity {
EditText usernameEdit,passwordEdit;
Button adminloginButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_adminlogin);
usernameEdit= (EditText) findViewById(R.id.adminusername);
passwordEdit= (EditText) findViewById(R.id.adminpassword);
adminloginButton= (Button) findViewById(R.id.adminlogin);
adminloginButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
if(usernameEdit.getText().toString().equals("admin")&&passwordEdit.get
Text().toString().equals("admin")) {
Intent in = new Intent(Adminlogin.this,
AdminHomeActivity.class);
startActivity(in);
}
else
{
Toast.makeText(Adminlogin.this,"Invalid username
or password",Toast.LENGTH_LONG).show();
}
}
});
}
@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_adminlogin, 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();