XML : Class not found exception found when inflating fragments

I was trying to include two fragments in my Main Activity but it causes a class not found exception problem

First Fragment Class(SearchFragment.class)

  public class SearchFragment extends Fragment{     public SearchFragment(){     }   @Override   public View onCreateView(LayoutInflater inflater, ViewGroup container,          Bundle savedInstanceState) {      // TODO Auto-generated method stub      return inflater.inflate(R.layout.search_fragment, container, false);   }    }    

First xml of Fragment(search_fragment.xml)

  <?xml version="1.0" encoding="utf-8"?>  <RelativeLayout 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:padding="5dp"  tools:context=".SearchFragment" >    <EditText      android:id="@+id/etSearch"      android:layout_width="wrap_content"      android:layout_height="40dp"      android:layout_alignParentLeft="true"      android:layout_alignParentTop="true"      android:layout_toLeftOf="@+id/butFilter"      android:background="@drawable/custom_form"      android:ems="10"      android:paddingRight="77dp" >  </EditText>    <Button      android:id="@+id/butFilter"      android:layout_width="40dp"      android:layout_height="40dp"      android:layout_alignParentRight="true"      android:layout_alignParentTop="true"      android:layout_marginLeft="5dp"      android:background="@drawable/custom_filter"      android:text="" />    <Button      android:id="@+id/butSearch"      android:layout_width="40dp"      android:layout_height="40dp"      android:layout_alignParentTop="true"      android:layout_alignRight="@+id/etSearch"      android:layout_marginLeft="10dp"      android:background="@drawable/custom_search"      android:padding="5dp"      android:text="" />    <Button      android:id="@+id/butDelete"      android:layout_width="25dp"      android:layout_height="25dp"      android:layout_alignParentTop="true"      android:layout_marginTop="7dp"      android:layout_toLeftOf="@+id/butSearch"      android:background="@drawable/custom_delete"      android:text="x" />    

Second Fragment Class(ContentFragment.class)

  public class ContentFragment extends Fragment {    public ContentFragment(){    }  @Override  public View onCreateView(LayoutInflater inflater, ViewGroup container,          Bundle savedInstanceState) {      // TODO Auto-generated method stub      return inflater.inflate(R.layout.content_fragment, container, false);  }  }    

Second xml fragment(content_fragment.xml)

  <?xml version="1.0" encoding="utf-8"?>  <RelativeLayout 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"      tools:context=".ContentFragment" >    </RelativeLayout>    

Main xml file(main.xml)

  <?xml version="1.0" encoding="utf-8"?>  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"      android:layout_width="match_parent"      android:layout_height="match_parent" >    <fragment      android:id="@+id/fragment1"      android:name="com.guru.alex.SearchFragment""      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:layout_alignParentLeft="true"      android:layout_alignParentTop="true" />    <fragment      android:id="@+id/fragment2"      android:name="com.guru.alex.ContentFragment""      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:layout_below="@+id/fragment1" />    <FrameLayout      android:layout_width="match_parent"      android:layout_height="match_parent" >        <SlidingDrawer          android:id="@+id/slidingDrawer1"          android:layout_width="wrap_content"          android:layout_height="match_parent"          android:content="@+id/content"          android:handle="@+id/handle"          android:orientation="horizontal"          android:rotation="180" >            <Button              android:id="@+id/handle"              android:layout_width="15dp"              android:layout_height="match_parent"              android:background="@android:color/transparent"              android:text=""              android:visibility="invisible" />            <RelativeLayout              android:id="@+id/content"              android:layout_width="wrap_content"              android:layout_height="match_parent"              android:background="#333"              android:orientation="vertical"              android:rotation="180" >                <TextView                  android:id="@+id/tvCat"                  android:layout_width="match_parent"                  android:layout_height="50dp"                  android:layout_alignParentLeft="true"                  android:layout_alignParentTop="true"                  android:background="#f37c20"                  android:gravity="center"                  android:text="Category"                  android:textAppearance="?android:attr/textAppearanceLarge"                  android:textColor="#333" />                <ExpandableListView                  android:id="@+id/elvItem"                  android:layout_width="match_parent"                  android:layout_height="match_parent"                  android:layout_below="@id/tvCat"                  android:animateLayoutChanges="true"                  android:divider="@drawable/custom_divider"                  android:dividerHeight="0dp"                  android:groupIndicator="@drawable/custom_group_indicator"                  android:transcriptMode="normal" >              </ExpandableListView>          </RelativeLayout>      </SlidingDrawer>        <SlidingDrawer          android:id="@+id/slidingDrawer2"          android:layout_width="250dp"          android:layout_height="match_parent"          android:layout_gravity="right"          android:content="@+id/content2"          android:handle="@+id/handle2"          android:orientation="horizontal" >            <Button              android:id="@+id/handle2"              android:layout_width="15dp"              android:layout_height="match_parent"              android:background="@android:color/transparent"              android:text=""              android:visibility="invisible" />            <RelativeLayout              android:id="@+id/content2"              android:layout_width="match_parent"              android:layout_height="match_parent"              android:background="#fff"              android:orientation="vertical" >                <ImageView                  android:id="@+id/imgUser"                  android:layout_width="match_parent"                  android:layout_height="150dp"                  android:layout_alignParentLeft="true"                  android:layout_alignParentTop="true"                  android:layout_marginBottom="10dp"                  android:background="#ccc"                  android:contentDescription="User Profile Picture"                  android:src="@drawable/default_user" />                <ExpandableListView                  android:id="@+id/elvSignIn"                  android:layout_width="match_parent"                  android:layout_height="match_parent"                  android:layout_alignParentLeft="true"                  android:layout_below="@+id/imgUser"                  android:animateLayoutChanges="true"                  android:dividerHeight="0dp"                  android:groupIndicator="@drawable/custom_group_indicator"                  android:indicatorLeft="180dp"                  android:transcriptMode="disabled" >              </ExpandableListView>          </RelativeLayout>      </SlidingDrawer>  </FrameLayout>    </RelativeLayout>    

No comments:

Post a Comment