title: Use Toast inside Fragment
body: <p>I'm trying to show a Toast Message when user click on a Button inside a Fragment. The problem is I cannot access the activity to show the Toast on it.</p>
  
  <p>Here's the source of <code>Fragment</code>:</p>
  
  <pre><code>    public class FrgTimes extends Fragment
      {
          ScrollView sv;
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                  Bundle savedInstanceState) 
          {
              if (container == null) { return null; }
  
              sv = (ScrollView)inflater.inflate(R.layout.frg_times, container, false);
  
              btnTime1.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
  
              //******  HERE's the PROBLEM  ********
              Toast.makeText(&lt;The Activity&gt;, "Please long press the key", Toast.LENGTH_LONG );
  
              }});
  
              return sv;
          }
  </code></pre>
  
  <p>and Here's what I've been tried.</p>
  
  <pre><code>Toast.makeText( getActivity()  , ...
  Toast.makeText( getView().getContext()  , ...
  Toast.makeText( getActivity().getApplicationContext()  , ...
  Toast.makeText( sv.getContext()  , ...
  Toast.makeText( sv.getRootView().getContext()  , ...
  </code></pre>
  
  <p>In Debug I can see that all of these codes run without any exception but no <code>TOAST</code> being displayed.</p>