title: How to get instance of view's parent fragment:
body: <p>I have a fragment with an <code>XML</code> layout file. in it I have an 2 clickable <code>ImageView</code>s.
  for each <code>ImageView</code> I set an <code>onClick</code> method for example: android:onClick="commentFragmentRemoveOnClick".</p>
  
  <p>In the FragmentActivity (The Activity no the Fragment) I defined it this way:</p>
  
  <pre><code>public void commentFragmentRemoveOnClick(View v)
  {
  
  }
  </code></pre>
  
  <p>No this Fragment is of type <code>CommentFragment</code> and it has a <code>public void getFragmentTag()</code>method
  to get it's tag that I save in earlier time. I need to get an instance of the fragment in which the image was clicked to get it's tag.</p>
  
  <p>I tried:</p>
  
  <pre><code>((CommentFragment)v).getParentFragment().getFragmentTag();
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>((CommentFragment)v).getParent().getFragmentTag();
  </code></pre>
  
  <p>but eclipse gives me error on both of them, how is this done properly?</p>
  
  <p>To make it more clear this is my <code>CommentFragment</code>:</p>
  
  <pre><code>public class CommentFragment extends Fragment {
  
  private final static String TAG = CommentFragment.class.getSimpleName(); 
  private String fragmentTag;
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState); 
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.comment_fragment_layout,
              container, false);
  
      Bundle bundle = getArguments();
      String text = bundle.getString("comment");
      String fullUser = bundle.getString("user");
      String user = fullUser.substring(0, fullUser.indexOf("@"));
      String at = bundle.getString("at");
  
      TextView tvCmment = (TextView) rootView.findViewById(R.id.tvComment);
      TextView tvUser = (TextView) rootView.findViewById(R.id.tvUser);
      TextView tvAt = (TextView) rootView.findViewById(R.id.tvDate);
  
      tvCmment.setText(text);
      tvUser.setText(user);
      tvAt.setText(at);
  
      return rootView;
  }
  
  public void setText(String item) 
  {
      TextView view = (TextView) getView().findViewById(R.id.tvComment);
      view.setText(item);
  }
  
  public void setFragmentTag(String tag)
  {
      this.fragmentTag = tag;
  }
  
  public String getFragmentTag()
  {
      return this.fragmentTag;
  }
   }
  </code></pre>
  
  <p>and the layout file:</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/llCommentContainer"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal" 
      android:background="@drawable/try2"&gt;
  
     &lt;TextView
         android:id="@+id/tvUser"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignLeft="@+id/tvComment"
         android:layout_alignParentTop="true"
         android:background="@color/my_gray"
         android:text="demo"
         android:textStyle="bold"
         android:paddingLeft="5dp"
         android:paddingRight="5dp"    
         android:textColor="@color/my_even_darker_gray" /&gt;
  
     &lt;TextView
         android:id="@+id/tvComment"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
         android:layout_below="@+id/tvDate"
         android:padding="5dp"
         android:text="This task is described in more details if you click on it."
         android:textColor="@color/my_even_darker_gray" /&gt;
  
     &lt;TextView
         android:id="@+id/tvAt"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentTop="true"
         android:paddingRight="5dp" 
         android:textColor="@color/my_even_darker_gray"
         android:layout_toRightOf="@+id/tvUser"
         android:background="@color/my_gray"
         android:text="at" /&gt;
  
     &lt;TextView
         android:id="@+id/tvDate"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_alignBaseline="@+id/tvAt"
         android:layout_alignBottom="@+id/tvAt"
         android:layout_toRightOf="@+id/tvAt"
         android:background="@color/my_gray"
         android:text="12/02"
         android:textColor="@color/my_even_darker_gray" /&gt;
  
      &lt;ImageView
          android:id="@+id/iEdit"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/tvComment"
          android:layout_marginRight="4dp"
          android:clickable="true"
          android:contentDescription="@drawable/add_comment_button"
          android:onClick="commentFragmentEditOnClick"
          android:src="@drawable/add_comment_button" /&gt;
  
      &lt;ImageView
          android:id="@+id/iRemove"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignTop="@+id/iEdit"
          android:layout_toRightOf="@+id/iEdit"
          android:layout_marginRight="4dp"
          android:clickable="true"
          android:contentDescription="@drawable/add_comment_button"
          android:onClick="commentFragmentRemoveOnClick"
          android:src="@drawable/add_comment_button" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I would love for a little assistance.</p>
  
  <p>Thanks.</p>