title: id attribute in fragments
body: <p>I am working on a app and it runs just fine but there is an problem that it crashes when I dont write id in my fragment code but runs fine after using id attribute and the problem is that i have not used it's id anywhere in my app</p>
  
  <p><strong>Here is the xml file</strong></p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="horizontal"
  &gt;
   &lt;fragment
    class="com.hfad.workout.WorkoutList"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="2"
    android:id="@+id/listfrag"
    /&gt;
   &lt;FrameLayout
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:text="second text view"
    android:layout_marginTop="20dp"
    android:id="@+id/fragcont"
    android:layout_weight="3"
    /&gt;
    &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>workoutlist.jav</strong></p>
  
  <pre><code> public class WorkoutList extends ListFragment {
  
      MainActivity ma;
   static interface WorkoutListListener{
   void clickme(long at);
   }
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          ArrayAdapter&lt;Workout&gt; arrayAdapter = new ArrayAdapter&lt;Workout&gt;(
                  inflater.getContext(), android.R.layout.simple_list_item_1, 
    Workout.workout);
          setListAdapter(arrayAdapter);
  
          return super.onCreateView(inflater, container, savedInstanceState);
      }
      @Override
      public void onAttach(Context ac){
          super.onAttach(ac);
          this.ma =(MainActivity) getActivity();
  
      }
  
      public void onListItemClick(ListView v, View vi, int position, long id){
          ma.clickme(id);
  
      }
  }
  </code></pre>