title: how to make if and else condition in android for setOnClickListener?
body: <p>i want to make an if else condition for setOnClickListener. how should i do it? the code below is working correctly. its just that i would like to make a condition. if user enter numbers more than 10000, i want the app to make a pop up alert to tell user to edit the number so that it will not exceed 10000. please help me on how to do it. below is the code in java. </p>
  
  <pre><code>package com.example.mobilecatering;
  
  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);
          phone.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  Toast msg = Toast.makeText(getBaseContext(), "Maximum 10000 only.", Toast.LENGTH_LONG);
                  msg.show();
              }
          });
  
          public void goReceipt(View v)  {
              Intent intent = new Intent(v.getContext(), doReceipt.class);
              intent.putExtra("phone", phone.getText().toString());
              startActivityForResult(intent,0); 
          }
      }
  }
  </code></pre>
  
  <p>this is the xml code.</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" &gt;
  
      &lt;ScrollView
          android:layout_width="match_parent"
          android:layout_height="match_parent" &gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical" &gt;
  
              &lt;TextView
                  android:id="@+id/textView50"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:textStyle="bold"
                  android:textAppearance="?android:attr/textAppearanceMedium"
                  android:text="Number of guest(s)"/&gt;
  
              &lt;EditText 
                  android:id="@+id/guest"
                  android:layout_width="fill_parent"
                  android:layout_height="50dp"   
                  android:inputType="number"
                  android:textStyle="bold"
                  android:textAppearance="?android:attr/textAppearanceMedium"
                  android:hint="Enter number 1 to 10 000 only." /&gt;
          &lt;/LinearLayout&gt;
  
  
      &lt;/ScrollView&gt;
  
  
  &lt;ImageButton
      android:id="@+id/gobutton"
      android:layout_width="60dp"
      android:layout_height="40dp"
      android:layout_alignTop="@+id/homebtn"
      android:layout_toRightOf="@+id/homebtn"
      android:background="@drawable/gobutton"
      android:onClick="goReceipt" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>User have to enter number in the EditText. after that when they click on GoButton to move to next page. if they enter number more than 10000, and they click on gobutton afterwards, the app suppose make an alert message for user and resume to the edittext after user click ok. how am i suppose to do that? help me please. </p>
  
  <p>any helps is appreciated.... :)</p>