[Android Studio] Samsul1993:
Hello, I am new to java and having difficulties trying to set a restriction on one of my editText.

I am trying to develop an app that allows user to fill there information in the application and then send through an email client.

So for my phone number section i am trying to make a restriction for only 11 characters to be entered, also for all the fields to be completed to process through the next stage.

here is my coding:

package com.example.rumel.booking2;

import android.content.Intent;

import android.support.v7.app.ActionBarActivity;

import android.os.Bundle;

import android.text.TextUtils;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

public class MainActivity extends ActionBarActivity implements View.OnClickListener {

EditText personName, numberGuests, phoneNumber, date, time;

String name, guests, number, dte, tme;

Button sendEmail;

[MENTION=439709]override[/MENTION]

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

initializerVars();

sendEmail.setOnClickListener(this);

}

private void initializerVars() {

personName = (EditText) findViewById(R.id.etName);

numberGuests = (EditText) findViewById(R.id.etGuest);

phoneNumber = (EditText) findViewById(R.id.etPhone);

date = (EditText) findViewById(R.id.etDate);

time = (EditText) findViewById(R.id.etTime);

sendEmail = (Button) findViewById(R.id.button);

}

public void onClick (View v) {

// TODO Auto-generated method stub

convertEditTextVarsIntoStringsAndYesThisIsAMethodWeCreated();

String[] to = new String[]{"samsul1993@hotmail.co.uk"};

String message = "Name: "

+ name

+ "\n"

+ " Number of Guests: "

+ guests

+ "\n"

+ " Contact Number: "

+ number

+ "\n"

+ " Date: "

+ dte

+ ", Time: "

+ tme

+ "\n"

+ "\n"

+ "Thank you";

Intent emailIntent = new Intent (Intent.ACTION_SEND);

emailIntent.putExtra(Intent.EXTRA_EMAIL, to);

emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Reservation");

emailIntent.putExtra(Intent.EXTRA_TEXT, message);

emailIntent.setType("message/rfc822");//rfc822 email protocol

startActivity(Intent.createChooser(emailIntent,"Email"));

}

private void convertEditTextVarsIntoStringsAndYesThisIsAMethodWeCreated() {

// TODO Auto-generated method stub

name = personName.getText().toString();

guests = numberGuests.getText().toString();

number = phoneNumber.getText().toString();

dte = date.getText().toString();

tme = time.getText().toString();

}

[MENTION=439709]override[/MENTION]

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.menu_main, menu);

return true;

}

[MENTION=439709]override[/MENTION]

protected void onPause() {

// TODO Auto-generated method stub

super.onPause();

finish();

}

[MENTION=439709]override[/MENTION]

public boolean onOptionsItemSelected(MenuItem item) {

// Handle action bar item clicks here. The action bar will

// automatically handle clicks on the Home/Up button, so long

// as you specify a parent activity in AndroidManifest.xml.

int id = item.getItemId();

//noinspection SimplifiableIfStatement

if (id == R.id.action_settings) {

return true;

}

return super.onOptionsItemSelected(item);

}

}

Would appreciate any help, thank you :)