package course.examples.helloWorldWithLogin;

import java.util.Random;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class LoginScreen extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loginscreen);

        final EditText uname = (EditText) findViewById(R.id.username_edittext);
        final EditText passwd = (EditText) findViewById(R.id.password_edittext);
        
        final Button loginButton = (Button) findViewById(R.id.login_button);
        loginButton.setOnClickListener(new OnClickListener() {
            
            public void onClick(View v) {
                
                if (checkPassword(uname.getText(), passwd.getText())) {
                    
                    // Create an explicit Intent for starting the HelloAndroid Activity 
                    Intent helloAndroidIntent = new Intent(LoginScreen.this,
                            HelloAndroid.class);
                    
                    // Use the Intent to start the HelloAndroid Activity 
                    startActivity(helloAndroidIntent);

                } else {
                    uname.setText("");
                    passwd.setText("");
                }
            }
        });
    }

    private boolean checkPassword(Editable uname, Editable passwd) {
        // Just pretending to extract text and check password
        return new Random().nextBoolean();
    }
}

@@ -676,25 +676,17 @@
 ttext);%0A
-        
 %0A
+
         
@@ -817,29 +817,17 @@
 ner() %7B%0A
-            
 %0A
+
         
@@ -860,33 +860,17 @@
 ew v) %7B%0A
-                
 %0A
+
         
@@ -933,36 +933,16 @@
 t())) %7B%0A
-                    
 %0A       
@@ -1004,32 +1004,55 @@
 the HelloAndroid
+%0A                    //
  Activity %0A     
@@ -1036,33 +1036,32 @@
      // Activity
- 
 %0A               
@@ -1171,36 +1171,16 @@
 class);%0A
-                    
 %0A       
@@ -1244,17 +1244,16 @@
 Activity
- 
 %0A       

remove tabs