title: Android: How to pass parameters from OnClickListener to another
body: <p>I'm new to android and Java. I wanna pass a variable (ac) from OnClickListener to another. I've tried this way, but i receive this error: cannot resolve symbol 'ac'. Can you help me please?</p>
  
  <pre><code>Button Calculate = (Button) theLayout.findViewById(R.id.button);
  Button buttonb = (Button) theLayout.findViewById(R.id.buttonb);
  final TextView tvac = (TextView) theLayout.findViewById(R.id.tvac);
  final TextView tvh = (TextView) theLayout.findViewById(R.id.tvh);
  final EditText eta = (EditText) theLayout.findViewById(R.id.eta);
  final EditText etn = (EditText) theLayout.findViewById(R.id.etn);
  final EditText etb = (EditText) theLayout.findViewById(R.id.etb);
  
  Calculate.setOnClickListener(new View.OnClickListener()
  {
      @Override
      public void onClick(View v)
      {
          Double a = new Double(eta.getText().toString());
          Double n = new Double(etn.getText().toString());
          Double ac = a*n;
          tvac.setText(getResources().getString(R.string.tvresultados2) + " " + ac);
      }
  });
  buttonb.setOnClickListener(new View.OnClickListener()
  {
      @Override
      public void onClick(View v) {
          double b = new Double(etb.getText().toString());
          double h = ac/b;          //error: cannot resolve symbol 'ac'
          tvh.setVisibility(View.VISIBLE);
          tvh.setText("h = " + h);
      }
  });
  </code></pre>