Validating User Input

by Toadster » Fri, 13 Mar 2009 06:58:31 GMT

Sponsored Links
 ello all,
In my quest to learn android, here is my next conundrum.
I have created a class that provides two EditText boxes in the UI.
I want to then launch one of two different classes, based on whether
or not the two inputs match.....password confirmation.

I have a similar situation in different areas of my program, in both
locations, the code chooses the same one each time, and I cannot get
it to choose the other by varying the input accordingly.

The code is below. Any help would be greatly appreciated.



package com.toadster.KMH;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class ChngLog2 extends Activity{
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {

EditText newlogin = (EditText) findViewById
final String NewLoginEntry = newlogin.getText().toString();

EditText conflogin = (EditText) findViewById
final String ConfLoginEntry = conflogin.getText().toString();

/*Find the Buttons from the XML Layout */

Button k = (Button)this.findViewById(;
k.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {

//Button Click Statements

if (NewLoginEntry.equals(ConfLoginEntry))
{final String login = NewLoginEntry;
Intent l = new Intent( ChngLog2.this,
startActivityForResult(l, 0x0341); }

else {
Intent v = new Intent(ChngLog2.this,
startActivityForResult(v, 0x0347);

***************************** .xml

// Beginning of the UI body

android:textSize = "15sp"
android:text="Enter NEW 4 Digit Login"

<EditText android:id = "@+id/login_entry_new"
android:password ="true"
android:hint = "####"

android:text=" "
android:text=" "

android:textSize = "15sp"
android:text="Confirm NEW 4 Digit Login"

<EditText android:id = &quo

Other Threads

1. Backup app via Email is possible on Android...

You want to be a little more clear about what you are saying?  All I can get
from this is that you have an app that allows the user to select another app
and e-mail it to someone else.  If so...  yes, the platform supports this,
it is no surprise.  And what is "tAttachApkInstaller" and what does it do
interesting besides the normal side-loading support in the platform?


2. Does styled text support html tag: <p> and <br> ?

Styled text supports: <b>,<i>, does it support more html tags, like
<p> or <br> ?

The code below is used for testing styled text:

        CharSequence str = getText(R.string.styled_text); //retrieve
the styled text as char sequence, so it won't lose any formatting
        TextView tv = (TextView)findViewById(;

I found only the <b> and <i> works, other tags just ignore the


3. Does styled text support html tag: <p> and <br> ?

4. How to create a project in android

5. the IP address of android market

6. AutoCompleteTextView without Adapter?

7. drawable, drawable-land, drawable-hdpi, drawable-mdpi, drawable-lpdi