Android: MessageBox not working
<p>I am trying to do some data verification. In short, when an add button is pressed, if certain fields are not filled in then I want to display a message box and return from further processing.</p>

<p>This is the flow of my code without the messageBox code:</p>

<pre><code>  Button add = (Button) findViewById(R.id.addButton);
    add.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {


            //local vars
            String access;
            String gender;
            String avail;
            String availCode;


            // getting values from selected editItems
            String name = textName.getText().toString();                
            String street = textStreet.getText().toString();                
            String city = textCity.getText().toString();                
            String state = textState.getText().toString();              
            String postal = textPostal.getText().toString();
            String country = textCountry.getText().toString();
            String directions = textDirections.getText().toString();
            String comments = textComments.getText().toString();


            //verify miniminal data
            if((name.equals("")) || (street.equals(""))|| (city.equals("")) || (state.equals("")) || (postal.equals("")) || (country.equals("")))
            {

            }
</code></pre>

<p>I tried pasting in this code:</p>

<pre><code>        //verify miniminal data
        if((name.equals("")) || (street.equals(""))|| (city.equals("")) || (state.equals("")) || (postal.equals("")) || (country.equals("")))
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setCancelable(false);
            builder.setTitle("Title");
            builder.setInverseBackgroundForced(true);
            builder.setMessage("Must enter minimal data.");
            builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                return;
              }
            });
            AlertDialog alert = builder.create();
            alert.show();

        }
</code></pre>

<p>But...I cannot get this line to build:</p>

<pre><code>AlertDialog.Builder builder = new AlertDialog.Builder(context);
</code></pre>

<p>Eclipse is saying context cannot be resolved to a variable.</p>

<p>I am confused as to what to do. Can someone help?</p>
