title: can not resolve getActivity() and getApplicationContext()
body: <p>I am learning android from <a href="https://youtu.be/V7HPQ6DVvug?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E" rel="nofollow noreferrer">Android Tutorial for Beginners 8 # wrap_content, fill_parent, Password Field and Toast in Android </a>
  using android studio 2.2.2.</p>
  
  <p>I have done the same as mentioned in tutorial but unable to understand why getApplicationContext() and getActivity methods are not resolvable.</p>
  
  <p>I have tried getActivity(), getActivity().getApplicationContext(), MainActivity.this.... etc. But Toast.makeText method unable to recognize Context.</p>
  
  <p>Can anyone please tell me what is the exact issue? and how can I resolve it?</p>
  
  <p><strong>Below is my code:</strong></p>
  
  <pre><code>package com.example.programingknowledge.myfirstapp;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  
  public class MainActivity extends AppCompatActivity {
  
  private EditText pass_word;
  private Button btn_sbm;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      addListenerOnButton();
  
  }
  
  public void addListenerOnButton() {
      pass_word = (EditText) findViewById(R.id.editText);
      btn_sbm = (Button) findViewById(R.id.button);
      final CharSequence passText = pass_word.getText().toString();
  
  
      btn_sbm.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Toast.makeText(getApplicationContext(),  passText, Toast.LENGTH_SHORT).show();
          }
      });
  }
  }
  </code></pre>
  
  <p><strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.programingknowledge.myfirstapp"&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity android:name=".MainActivity"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/activity_main"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="com.example.programingknowledge.myfirstapp.MainActivity"
  android:background="@android:color/black"&gt;
  
  &lt;EditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:inputType="textPassword"
      android:ems="10"
      android:layout_alignParentTop="true"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:id="@+id/editText" /&gt;
  
  &lt;Button
      android:text="Button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="23dp"
      android:id="@+id/button"
      android:layout_below="@+id/editText"
      android:layout_centerHorizontal="true" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>