title: Android error when opening new activity from listview
body: <p>I`m new to android development, i try to open a new activity from a listview and than also receive the data from the listview.
  when i click than on the listview item i get always the following error code: </p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                Process: development.wrabel.sunshine, PID: 2420
                java.lang.RuntimeException: Unable to start activity ComponentInfo{development.wrabel.sunshine/development.wrabel.sunshine.DetailActivity}: android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class fragment
                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                    at android.app.ActivityThread.-wrap12(ActivityThread.java)
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                    at android.os.Handler.dispatchMessage(Handler.java:102)
                    at android.os.Looper.loop(Looper.java:154)
                    at android.app.ActivityThread.main(ActivityThread.java:6077)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                 Caused by: android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class fragment
                 Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
                 Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment development.wrabel.sunshine.DetailActivityFragment: make sure class name exists, is public, and has an empty constructor that is public
                    at android.app.Fragment.instantiate(Fragment.java:629)
                    at android.app.Fragment.instantiate(Fragment.java:593)
                    at android.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2302)
                    at android.app.FragmentController.onCreateView(FragmentController.java:98)
                    at android.app.Activity.onCreateView(Activity.java:5884)
                    at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:36)
                    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:75)
                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:777)
                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
                    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
                    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                    at development.wrabel.sunshine.DetailActivity.onCreate(DetailActivity.java:21)
                    at android.app.Activity.performCreate(Activity.java:6664)
                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                    at android.app.ActivityThread.-wrap12(ActivityThread.java)
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                    at android.os.Handler.dispatchMessage(Handler.java:102)
                    at android.os.Looper.loop(Looper.java:154)
                    at android.app.ActivityThread.main(ActivityThread.java:6077)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                 Caused by: java.lang.ClassNotFoundException: Didn't find class "development.wrabel.sunshine.DetailActivityFragment" on path: DexPathList[[zip file "/data/app/development.wrabel.sunshine-1/base.apk"],nativeLibraryDirectories=[/data/app/development.wrabel.sunshine-1/lib/x86, /system/lib, /vendor/lib]]
                    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
                    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                    at android.app.Fragment.instantiate(Fragment.java:615)
                    at android.app.Fragment.instantiate(Fragment.java:593) 
                    at android.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2302) 
                    at android.app.FragmentController.onCreateView(FragmentController.java:98) 
                    at android.app.Activity.onCreateView(Activity.java:5884) 
                    at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:36) 
                    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:75) 
                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:777) 
                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:495) 
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:377) 
                    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                    at development.wrabel.sunshine.DetailActivity.onCreate(DetailActivity.java:21) 
                    at android.app.Activity.performCreate(Activity.java:6664) 
                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 
                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) 
                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) 
                    at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) 
                    at android.os.Handler.dispatchMessage(Handler.java:102) 
                    at android.os.Looper.loop(Looper.java:154) 
                    at android.app.ActivityThread.main(ActivityThread.java:6077) 
                    at java.lang.reflect.Method.invoke(Native Method) 
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
  </code></pre>
  
  <p>This is the code of the main activity: 
  listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {</p>
  
  <pre><code>        @Override
          public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int position, long l) {
              String forecast = mForecastAdapter.getItem(position);
              Intent intent = new Intent(getActivity(), DetailActivity.class)
                      .putExtra(Intent.EXTRA_TEXT, forecast);
              startActivity(intent);
          }
      });
  </code></pre>
  
  <p>Please help me with the problem, thanks in advance!</p>
  
  <p>Update - here is the code from the Android Manifest:</p>
  
  <pre><code>&lt;activity
          android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@style/AppTheme.NoActionBar"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name="development.wrabel.sunshine.DetailActivity"
          android:label="@string/title_activity_detail"
          android:parentActivityName="development.wrabel.sunshine.MainActivity"&gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="development.wrabel.sunshine.MainActivity" /&gt;
      &lt;/activity&gt;
  </code></pre>
  
  <p>Update - here is the Detail Activity java and xml</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_detail);
      if (savedInstanceState == null) {
          getSupportFragmentManager().beginTransaction()
                  .add(R.id.container, new DetailFragment())
                  .commit();
      }
  }
  
  public static class DetailFragment extends Fragment {
  
      public DetailFragment() {
          setHasOptionsMenu(true);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          View rootView = inflater.inflate(R.layout.fragment_detail, container, false);
  
          // The detail Activity called via intent.  Inspect the intent for forecast data.
          Intent intent = getActivity().getIntent();
          if (intent != null &amp;&amp; intent.hasExtra(Intent.EXTRA_TEXT)) {
              mForecastStr = intent.getStringExtra(Intent.EXTRA_TEXT);
              ((TextView) rootView.findViewById(R.id.detailText))
                      .setText(mForecastStr);
          }
  
          return rootView;
      }
  </code></pre>
  
  <p>here is the xml</p>
  
  <pre><code>&lt;fragment xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/container"
  android:name="development.example.sunshine.DetailActivity"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:layout="@layout/fragment_detail" /&gt;
  </code></pre>
  
  <p>and the xml of the fragment</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/container"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="development.wrabel.sunshine.DetailActivity"&gt;
  &lt;TextView
      android:text="TextView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/detailText" /&gt;
  </code></pre>
  
  <p></p>