Click here to Skip to main content
15,879,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everyone. i am developing an android application now. i have this kind of problem. i have an edit text. in this form, user have to fill in the edittext. they are not suppose to be allowed to proceed to next page if they do not enter number in the edittext. below is the code for my project. help me plz.

Java
package com.example.mobilecatering;


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.CheckBox;
import android.widget.EditText;
import android.widget.Toast;

public class mcpakej1 extends Activity 
{
	private EditText phone;
	
	public void onCreate(Bundle savedInstanceState) 
	{
	  super.onCreate(savedInstanceState);
	  setContentView(R.layout.mcpakej1);

	  

		phone = (EditText) findViewById(R.id.guest);
		findViewById(R.id.gobutton).setOnClickListener(new OnClickListener() {
		
			@Override
		public void onClick(View v) {

					final String pass = phone.getText().toString();
					if (!isValidPassword(pass)) {
						phone.setError("Invalid Number");
					}

				}
			});
}
	 
	public void goReceipt(View v) 
	{
		Intent intent = new Intent(v.getContext(), doReceipt.class);
		intent.putExtra("phone", phone.getText().toString());
		startActivityForResult(intent,0);
  	}
	private boolean isValidPassword(String pass) 
	{
		if (pass != null && pass.length() <= 10000) 
		{
			return true;
		}
		return false;
	}
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900