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.

Tad

******************************.java
class******************************************************************

package com.toadster.KMH;

import android.app.Activity;
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. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.chnglog2);




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


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


/*Find the Buttons from the XML Layout */

Button k = (Button)this.findViewById(R.id.btn_next);
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,
UpdateConfirm.class);
startActivityForResult(l, 0x0341); }


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


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

// Beginning of the UI body

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize = "15sp"
android:text="Enter NEW 4 Digit Login"
/>

<EditText android:id = "@+id/login_entry_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:password ="true"
android:hint = "####"
/>

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=" "
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=" "
/>

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize = "15sp"
android:text="Confirm NEW 4 Digit Login"
/>

<EditText android:id = &quo



Other Threads

1. Start application when device is on power

Hi,
How do I start an application when the device runs on ac-power? It
should start when the cable has been plugged in.. Is this possible?

Thank you very much,
//Kaloer
--~--~---------~--~----~------------~-------~--~----~

2. LogCat problem with two emulators open

Hi all,

Ive created two AVDs to test my application.

So I have two emulators running in port 5554 and 5556.

But the LogCat view shows the messages from both emulators. Even if
you select just the process you desire in the Devices View, the LogCat
still shows both messages..

is it a bug ?

thank you
Ricardo
--~--~---------~--~----~------------~-------~--~----~

3. Animation Xml Resource and CycleInterpolator tag: FAIL

4. 1.5 ListView disabled items

5. AppWidget issues

6. Animation Xml Resource and CycleInterpolator tag: FAIL

7. AppWidgets: Dynamic value for updatePeriodMillis?