java - InflateException Binary XML file at line #7: Error inflating class fragment -


i've been doing research of problem no solution has yet work me. i've added empty constructors in fragment classes , tried different imports of fragments, nothing seems work. hope guys can me!

my activity:

package com.example.com.example.android.rssfeed;  import android.app.activity; import android.os.bundle;  public class rssfeedactivity extends activity implements mylistfragment.onitemselectedlistener {  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_rssfeed); }  public void onrssitemselected(string link) {     detailfragment fragment = (detailfragment) getfragmentmanager().findfragmentbyid(r.id.detailfragment);      if (fragment != null && fragment.isinlayout()) {         fragment.settext(link);     }//end if }//end method onrssitemselected  }//end class 

my fragment:

package com.example.com.example.android.rssfeed; import android.app.activity; import android.os.bundle; import android.app.fragment; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.button;   public class mylistfragment extends fragment {  public mylistfragment() {  }  private onitemselectedlistener listener;   @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     view view = inflater.inflate(r.layout.fragment_rsslist_overview, container, false);     button button = (button) view.findviewbyid(r.id.btn1);     button.setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view v) {             updatedetail();         }//end onclick     });     return view; }//end oncreateview  public interface onitemselectedlistener {     public void onrssitemselected(string link); }//end onitemselectedlistener  @override     public void onattach(activity activity) {     super.onattach(activity);          if (activity instanceof onitemselectedlistener) {             listener = (onitemselectedlistener) activity;          } else {             throw new classcastexception(activity.tostring()                     + "must implement mylistfragment.onitemselectedlistener");         }//end else  }//end onattach  //may triggered activity public void updatedetail() {     //create fake data     string newtime = string.valueof(system.currenttimemillis());     // send data activity     listener.onrssitemselected(newtime); }//end method updatedetail }//end class 

my fragment xml:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:baselinealigned="false" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" >      <fragment         android:id="@+id/listfragment"          android:layout_width="0dp"         android:layout_weight="1"         android:layout_height="match_parent"         class="com.example.android.rssfeed.mylistfragment"         android:layout_margintop="?android:attr/actionbarsize"></fragment>        <fragment         android:id="@+id/detailfragment"         android:layout_width="0dp"         android:layout_weight="2"         android:layout_height="match_parent"         class="com.example.android.rssfeed.detailfragment"></fragment>     </linearlayout> 

manifest:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.com.example.android.rssfeed" android:versioncode="1" android:versionname="1.0" >  <uses-sdk     android:minsdkversion="12"     android:targetsdkversion="19" />  <application     android:allowbackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >     <activity         android:name="com.example.com.example.android.rssfeed.rssfeedactivity"         android:label="@string/app_name" >         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity> </application> 

button xml:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >  <button     android:id="@+id/btn1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="press update">  </button> </linearlayout> 

logcat error:

05-17 10:35:01.864: e/androidruntime(6384): fatal exception: main 05-17 10:35:01.864: e/androidruntime(6384): java.lang.runtimeexception: unable start activity componentinfo{com.example.com.example.android.rssfeed/com.example.com.example.android.rssfeed.rssfeedactivity}: android.view.inflateexception: binary xml file line #7: error inflating class fragment 05-17 10:35:01.864: e/androidruntime(6384):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2245) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2295) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.app.activitythread.access$700(activitythread.java:150) 05-17 10:35:01.864: e/androidruntime(6384):     @  android.app.activitythread$h.handlemessage(activitythread.java:1280) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.os.handler.dispatchmessage(handler.java:99) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.os.looper.loop(looper.java:137) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.app.activitythread.main(activitythread.java:5279) 05-17 10:35:01.864: e/androidruntime(6384):     @ java.lang.reflect.method.invokenative(native method) 05-17 10:35:01.864: e/androidruntime(6384):     @ java.lang.reflect.method.invoke(method.java:511) 05-17 10:35:01.864: e/androidruntime(6384):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) 05-17 10:35:01.864: e/androidruntime(6384):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) 05-17 10:35:01.864: e/androidruntime(6384):     @ dalvik.system.nativestart.main(native method) 05-17 10:35:01.864: e/androidruntime(6384): caused by: android.view.inflateexception: binary xml file line #7: error inflating class fragment 05-17 10:35:01.864: e/androidruntime(6384):     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:710) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.view.layoutinflater.rinflate(layoutinflater.java:752) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.view.layoutinflater.inflate(layoutinflater.java:495) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.view.layoutinflater.inflate(layoutinflater.java:397) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.view.layoutinflater.inflate(layoutinflater.java:353) 05-17 10:35:01.864: e/androidruntime(6384):     @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:342) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.app.activity.setcontentview(activity.java:1928) 05-17 10:35:01.864: e/androidruntime(6384):     @ com.example.com.example.android.rssfeed.rssfeedactivity.oncreate(rssfeedactivity.java:11) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.app.activity.performcreate(activity.java:5267) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1097) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2209) 05-17 10:35:01.864: e/androidruntime(6384):     ... 11 more 05-17 10:35:01.864: e/androidruntime(6384): caused by: android.app.fragment$instantiationexception: unable instantiate fragment com.example.android.rssfeed.mylistfragment: make sure class name exists, public, , has empty constructor public 05-17 10:35:01.864: e/androidruntime(6384):     @ android.app.fragment.instantiate(fragment.java:592) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.app.fragment.instantiate(fragment.java:560) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.app.activity.oncreateview(activity.java:4862) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:686) 05-17 10:35:01.864: e/androidruntime(6384):     ... 21 more 05-17 10:35:01.864: e/androidruntime(6384): caused by: java.lang.classnotfoundexception: didn't find class "com.example.android.rssfeed.mylistfragment" on path: /data/app/com.example.com.example.android.rssfeed-1.apk 05-17 10:35:01.864: e/androidruntime(6384):     @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:65) 05-17 10:35:01.864: e/androidruntime(6384):     @ java.lang.classloader.loadclass(classloader.java:501) 05-17 10:35:01.864: e/androidruntime(6384):     @ java.lang.classloader.loadclass(classloader.java:461) 05-17 10:35:01.864: e/androidruntime(6384):     @ android.app.fragment.instantiate(fragment.java:582) 05-17 10:35:01.864: e/androidruntime(6384):     ... 24 more 

caused by: java.lang.classnotfoundexception: didn't find class "com.example.android.rssfeed.mylistfragment" on path: /data/app/com.example.com.example.android.rssfeed-1.apk

change this

 class="com.example.android.rssfeed.mylistfragment" 

to

 class="com.example.com.example.android.rssfeed.mylistfragment" 

cause packagename package com.example.com.example.android.rssfeed.

similarly

 class="com.example.com.example.android.rssfeed.detailfragment" 

if package name same

change this

<button android:id="@+id/btn1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="press update"> 

to

<button android:id="@+id/btn1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="press update" /> 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -