Help Making App

Discussion in 'Android App Developers' started by DHood, Jan 21, 2010.

  1. DHood

    DHood Member

    Joined:
    Dec 9, 2009
    Messages:
    91
    Likes Received:
    0
    Trophy Points:
    6
    Ratings:
    +0
    Hello,

    I've never coded with java before (I know this isn't really java but still). I have coded, ajax, php, javascript, (x)html, css.

    I'm just trying to make something to learn like the basics and get an idea of how to code for android. I'm making an app that starts with a lock screen, you enter a password and then click a button and it either says "Failed" or it takes you to the main screen.

    I have this as my code right now but it's not working (I'm guessing because of the setContentView code at the bottom, I'm trying to figure out how to switch "parts" of the app). Here's my code:

    Code:
    package com.hood.assistant;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.text.Editable;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    
    public class Assistant extends Activity {
    	public EditText myPassword;
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
        	super.onCreate(savedInstanceState);
            setContentView(R.layout.lock);
            Button confirmButton = (Button) findViewById(R.id.confirm);
            myPassword = (EditText) findViewById(R.id.EditText01);
            confirmButton.setOnClickListener(new View.OnClickListener()
            {
    			public Editable enteredText;
    			private EditText myResult;
    			public void onClick(View view) {
    				enteredText = myPassword.getText();
    				myResult = (EditText) findViewById(R.id.result);
    				if (enteredText.toString().equals("hood")){
    					setContentView(R.layout.main);
    				}
    				else
    					myResult.setVisibility(0);
    				
    			}
            });
        }
    }
    
    I got here by messing with Notepad Tutorial. Please, any assistance at all.

    Sorry in advance if this isn't the right place or if there isn't even a place for this...