title: Android - Displaying Customized Toast in ListFragment throws an Error
body: <p>I didn't find any post to display customized toast in ListFragment. I have search all around.
  Here is my customized xml file used to display a toast.</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/relativeLayout5"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#CC000000" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:gravity="center"
          android:text="@string/course_deleted"
          android:textAppearance="?android:attr/textAppearanceLarge"
          android:textColor="@android:color/white" &gt;
      &lt;/TextView&gt;
  
      &lt;ImageView
          android:id="@+id/imageView1"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/textView1"
          android:layout_margin="5dip"
          android:contentDescription="@string/delete"
          android:src="@drawable/ic_action_discard" &gt;
      &lt;/ImageView&gt;
  
      &lt;TextView
          android:id="@+id/textView2"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/imageView1"
          android:gravity="center"
          android:textColor="@android:color/white" &gt;
      &lt;/TextView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and a method that inflate this xml is:</p>
  
  <pre><code>private void delete(String course) {
      DatabaseHandler db = new DatabaseHandler(this.getActivity());
      boolean status = db.deleteCourse(UNI, course);
      if (status) {
          view = inflater.inflate(
                  R.layout.custom_toast_layout_course_deleted,
                  (ViewGroup) getActivity()
                          .findViewById(R.id.relativeLayout5));
  
          Toast toast = new Toast(getActivity());
          toast.setGravity(Gravity.TOP, 0, 0);
          toast.setDuration(Toast.LENGTH_SHORT);
          toast.setView(view);
          toast.show();
      }
  }
  </code></pre>
  
  <p>But when my app runs it show this error:</p>
  
  <pre><code>11-13 09:48:13.521: E/AndroidRuntime(11052): FATAL EXCEPTION: main
  11-13 09:48:13.521: E/AndroidRuntime(11052): java.lang.NullPointerException
  11-13 09:48:13.521: E/AndroidRuntime(11052):    at ......delete(POKFragment.java:173)
  11-13 09:48:13.521: E/AndroidRuntime(11052):    at ......access$0(POKFragment.java:161)
  11-13 09:48:13.521: E/AndroidRuntime(11052):    at ......onClick(POKFragment.java:107)
  </code></pre>
  
  <p>and Line 173 is:</p>
  
  <pre><code>view = inflater.inflate(R.layout.custom_toast_layout_course_deleted,(ViewGroup) getActivityity().findViewById(R.id.relativeLayout5));
  </code></pre>
  
  <p>What is wrong in this code? It works fine for Activity but goes wrong with ListFragment.</p>