Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //For Login.java
- package com.mark.uricacidevaluator;
- import android.support.v7.app.ActionBarActivity;
- import android.os.Bundle;
- import android.content.Intent;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.Toast;
- public class Login extends ActionBarActivity {
- Button login,newuser;
- EditText uname,pword;
- SqliteController handler;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.login);
- login = (Button)findViewById(R.id.login);
- newuser = (Button)findViewById(R.id.register);
- uname = (EditText)findViewById(R.id.text_uname);
- pword = (EditText)findViewById(R.id.text_pword);
- newuser.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- // TODO Auto-generated method stub
- Intent myIntent = new Intent(view.getContext(), Register.class);
- startActivityForResult(myIntent, 0);
- finish();
- }
- });
- login.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- // TODO Auto-generated method stub
- if ( ( !uname.getText().toString().equals("")) && ( !pword.getText().toString().equals("")) )
- {
- Intent myIntent = new Intent(view.getContext(), Content.class);
- startActivityForResult(myIntent, 0);
- finish();
- }
- else if ( ( !uname.getText().toString().equals("")) )
- {
- Toast.makeText(getApplicationContext(),
- "Password field empty", Toast.LENGTH_SHORT).show();
- }
- else if ( ( !pword.getText().toString().equals("")) )
- {
- Toast.makeText(getApplicationContext(),
- "Email field empty", Toast.LENGTH_SHORT).show();
- }
- else
- {
- Toast.makeText(getApplicationContext(),
- "Email and Password field are empty", Toast.LENGTH_SHORT).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.login, 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();
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement