title: How to pass values from layout inflater in android
body: <p>I am using layout inflater to get value for amount and vat using edit text in layout inflater.When the user press the save button it stores the value in text view.
  I want the values stored in text view layout inflater to Main Activity.I have tried declaring the values globally but it is not working.</p>
  
  <pre><code>LayoutInflater repcard=LayoutInflater.from(Cam.this);
      View promptView=repcard.inflate(R.layout.moneyreceipt,null);
      AlertDialog.Builder alertDialogBuilder=new AlertDialog.Builder(Cam.this);
      alertDialogBuilder.setView(promptView);
     final EditText amt=(EditText)promptView.findViewById(R.id.edamt);
     final EditText vta=(EditText)promptView.findViewById(R.id.edvat);
     final TextView  tvs=(TextView)promptView.findViewById(R.id.tvamount);
     final TextView tvat=(TextView)promptView.findViewById(R.id.tvvat);
  
      final Button save=(Button)promptView.findViewById(R.id.btnmoneysave);
      tvs.setText(amt.getText().toString());
      tvat.setText(vta.getText().toString());
      amount=tvs.getText().toString();
      vat=tvat.getText().toString();
      save.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Toast.makeText(Cam.this, amount, Toast.LENGTH_LONG).show();
              Toast.makeText(Cam.this, vat, Toast.LENGTH_LONG).show();
  
              detailsreceiptupload();
  
          }
      });
      AlertDialog alert = alertDialogBuilder.create();
      alert.show();
  </code></pre>
  
  <p>In this the variables amount and vat are declared globally.</p>