package edu.nettester;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.support.v4.app.TaskStackBuilder;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;

public class LoginActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        
        //enable the app icon as an Up button
        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            
            // Respond to the action bar's Up/Home button
            case android.R.id.home:
                Intent upIntent = NavUtils.getParentActivityIntent(this);
                upIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP); //need to still have the same state on the main activity
                
                if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
                    // This activity is NOT part of this app's task, so create a new task
                    // when navigating up, with a synthesized back stack.
                    TaskStackBuilder.create(this)
                            // Add all of this activity's parents to the back stack
                            .addNextIntentWithParentStack(upIntent)
                            // Navigate up to the closest parent
                            .startActivities();
                } else {
                    // This activity is part of this app's task, so simply
                    // navigate up to the logical parent activity.
                    NavUtils.navigateUpTo(this, upIntent);
                }
                return true;
                
            default:
                return super.onOptionsItemSelected(item);
        }
    }
}

@@ -286,387 +286,2180 @@
 em;%0A
-%0Apublic class LoginActivity extends ActionBarActivity %7B%0A%0A    @Override%0A    protected void onCreate(Bundle savedInstanceState) %7B%0A        super.onCreate(savedInstanceState);%0A        setContentView(R.layout.activity_login);%0A        %0A        //enable the app icon as an Up button%0A        ActionBar actionBar = getSupportActionBar();%0A        actionBar.setDisplayHomeAsUpEnabled(true);
+import android.view.View;%0Aimport android.view.View.OnClickListener;%0Aimport android.widget.Button;%0Aimport android.widget.EditText;%0Aimport android.widget.Toast;%0A%0Apublic class LoginActivity extends ActionBarActivity %7B%0A    %0A    private Button btn_login;%0A    private Button btn_signup;%0A    private EditText edit_email;%0A    private EditText edit_pwd;%0A%0A    @Override%0A    protected void onCreate(Bundle savedInstanceState) %7B%0A        super.onCreate(savedInstanceState);%0A        setContentView(R.layout.activity_login);%0A        %0A        //enable the app icon as an Up button%0A        ActionBar actionBar = getSupportActionBar();%0A        actionBar.setDisplayHomeAsUpEnabled(true);%0A        %0A        findViews();%0A        initButtons();%0A    %7D%0A    %0A    private void findViews() %7B%0A        btn_login = (Button) findViewById(R.id.btn_login);%0A        btn_signup = (Button) findViewById(R.id.btn_signup);%0A        edit_email = (EditText) findViewById(R.id.edit_email);%0A        edit_pwd = (EditText) findViewById(R.id.edit_pwd);%0A    %7D%0A    %0A    private void initButtons() %7B%0A        btn_login.setOnClickListener(new OnClickListener() %7B%0A            @Override%0A            public void onClick(View v) %7B%0A                String str_email = edit_email.getText().toString();%0A                String str_pwd = edit_pwd.getText().toString();%0A                %0A                if (str_email.isEmpty() %7C%7C str_pwd.isEmpty()) %7B%0A                    Toast.makeText(LoginActivity.this, %22Email or password should be not null%22, Toast.LENGTH_SHORT)%0A                         .show();%0A                %7D else %7B%0A                    if (sendLoginData(str_email, str_pwd)) %7B%0A                        // TODO login success%0A                    %7D%0A                %7D%0A            %7D%0A        %7D);%0A        %0A        btn_signup.setOnClickListener(new OnClickListener() %7B%0A            @Override%0A            public void onClick(View v) %7B%0A                // TODO%0A                openSignUpActivity();%0A            %7D%0A        %7D);%0A    %7D%0A    %0A    public boolean sendLoginData(String str_email, String str_pwd) %7B%0A        // TODO%0A        %0A        return false;%0A    %7D%0A    %0A    /**%0A     * TODO%0A     */%0A    private void openSignUpActivity() %7B%0A        
 %0A   

handle UI events in LoginActivity