title: Null Pointer Exception: addTextChangedListener
body: <p>In my application, there are two <code>AutoCompleteTextView</code> and a <code>Button</code> to calculate a certain operation. I am setting the <code>Button</code> responsive to the two <code>AutoCompleteTextView</code> in the sense that, if both of the <code>AutoCompleteTextView</code> are filled, only then should the <code>Button</code> appear.</p>
  
  <p>Doing this I am getting a <strong>Null Pointer Exception</strong>. The program is as follows:</p>
  
  <pre><code>boolean isLocation=false;
  boolean isDestination=false;
  
  protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          location=(AutoCompleteTextView)findViewById(R.id.locale);
          location.setAdapter(new PlacesAutoCompleteAdapter(this, R.layout.list_item));
          location.setOnItemClickListener(new OnItemClickListener()
  
      {
  
      @Override
      public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int position, long id) {
              // TODO Auto-generated method stub
              place1 = (Places) adapterView.getItemAtPosition(position);
              location.setText(place1.description);
              location.clearFocus();
              destination.requestFocus();
              Log.d("AutoCompleteTask", location.getText().toString());
                  }
      });
  
      location.addTextChangedListener(new TextWatcher()
      {
  
          @Override
          public void afterTextChanged(Editable arg0) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count,
                  int after) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before,
                  int count) {
              // TODO Auto-generated method stub
              fillLocation=true;
          }
  
      });
  
  
      destination = (AutoCompleteTextView)findViewById(R.id.destination);
      destination.setAdapter(new PlacesAutoCompleteAdapter(this, R.layout.list_item));
      destination.setOnItemClickListener(new OnItemClickListener() 
      {
  
      @Override
      public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int position, long id) {
                  // TODO Auto-generated method stub
              place2 = (Places) adapterView.getItemAtPosition(position);
              destination.setText(place2.description);
              destination.clearFocus();
              calculate.requestFocus();               
              Log.d("AutoCompleteTask2", destination.getText().toString());
                  }
      });
  
      destination.addTextChangedListener(new TextWatcher() {
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count,
                  int after) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void afterTextChanged(Editable s) {
              // TODO Auto-generated method stub
              fillDestination=true;
          }
      });
  
      if(fillLocation==true || fillDestination==true )
      {
          calculate.setVisibility(View.VISIBLE);
      }
      else
      {
          calculate.setVisibility(View.INVISIBLE);
      }
  
  
      calculate = (Button)findViewById(R.id.calculate);
      calculate.setOnClickListener(new View.OnClickListener() {
  
  
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
  
              if(location.getText().toString().length()&lt;1 || destination.getText().toString().length()&lt;1) 
              {
                  Toast.makeText(getApplicationContext(), "Give values before placing a query", Toast.LENGTH_LONG).show();
              }
              else{
                  @SuppressWarnings("deprecation")
                  String url = "http://maps.googleapis.com/maps/api/distancematrix/json?origins="+URLEncoder.encode(location.getText().toString())+"&amp;destinations="+URLEncoder.encode(destination.getText().toString())+"&amp;unit=metric&amp;mode=driving&amp;sensor=false";
                  new ReadDistanceJSONFeedTask().execute(url);
                  }
              }
          });
  </code></pre>
  
  <p>Being new to developing apps, what is this <strong>Null Pointer Exception</strong>? Can someone please help ?</p>