title: How to pass edit Text value to Toast?
body: <p>I've just started with android and I'm trying to make simple program to take string from user and display the result as <code>Toast</code></p>
  
  <pre><code>EditText e = (EditText) findViewById(R.id.editText);
  final String result = e.getText().toString();
  Button btx = (Button) findViewById(R.id.button2);
  btx.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(View v) {
           Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
       }
  }
  </code></pre>
  
  <p>Now If I type anything in <code>editText</code> it's supposd to print that value but instead it's printing the default text value and even if I edit that it prints the same value</p>
  
  <p><a href="https://i.stack.imgur.com/ZKSz8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZKSz8.png" alt="enter image description here"></a>
  As you can see in the picture on pressing the button it shows "Name" on toast<br>
  and even upon changing it shows the same thing that is "Name". I want it too show the value that I typed later.
  What should I do?</p>