android - MergeAdapter ClassCastException only w/ Genymotion -


i getting class cast exception occurs when using genymotion. whenever try on real device not have issue.

stacktrace:

5-11 19:05:10.217    1278-1278/com.vast.homestory.betadebug e/androidruntime﹕ fatal exception: main java.lang.classcastexception: android.widget.framelayout$layoutparams cannot cast android.widget.abslistview$layoutparams         @ android.widget.listview.setupchild(listview.java:1874)         @ android.widget.listview.makeandaddview(listview.java:1843)         @ android.widget.listview.filldown(listview.java:675)         @ android.widget.listview.fillfromtop(listview.java:736)         @ android.widget.listview.layoutchildren(listview.java:1655)         @ android.widget.abslistview.onlayout(abslistview.java:2012)         @ android.view.view.layout(view.java:14289)         @ android.view.viewgroup.layout(viewgroup.java:4562)         @ android.widget.relativelayout.onlayout(relativelayout.java:1076)         @ android.view.view.layout(view.java:14289)         @ android.view.viewgroup.layout(viewgroup.java:4562)         @ android.widget.framelayout.onlayout(framelayout.java:448)         @ android.view.view.layout(view.java:14289)         @ android.view.viewgroup.layout(viewgroup.java:4562)         @ android.widget.framelayout.onlayout(framelayout.java:448)         @ android.view.view.layout(view.java:14289)         @ android.view.viewgroup.layout(viewgroup.java:4562)         @ com.android.internal.widget.actionbaroverlaylayout.onlayout(actionbaroverlaylayout.java:349)         @ android.view.view.layout(view.java:14289)         @ android.view.viewgroup.layout(viewgroup.java:4562)         @ android.widget.framelayout.onlayout(framelayout.java:448)         @ android.view.view.layout(view.java:14289)         @ android.view.viewgroup.layout(viewgroup.java:4562)         @ android.view.viewrootimpl.performlayout(viewrootimpl.java:1976)         @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1730)         @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1004)         @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:5481)         @ android.view.choreographer$callbackrecord.run(choreographer.java:749)         @ android.view.choreographer.docallbacks(choreographer.java:562)         @ android.view.choreographer.doframe(choreographer.java:532)         @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:735)         @ android.os.handler.handlecallback(handler.java:730)         @ android.os.handler.dispatchmessage(handler.java:92)         @ android.os.looper.loop(looper.java:137)         @ android.app.activitythread.main(activitythread.java:5103)         @ java.lang.reflect.method.invokenative(native method)         @ java.lang.reflect.method.invoke(method.java:525)         @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737)         @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553)         @ dalvik.system.nativestart.main(native method) 

i using merge adapter commonsware , code:

@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {      viewgroup v = (viewgroup)  inflater.inflate(r.layout.fragment_profile_merge_list, container, false);      initviews(inflater, container, v);      setviews();      setlistadapter(mergeadapter);      return v; }       public void initviews(layoutinflater inflater, viewgroup container, view v) {      progressbar = (progressbar) v.findviewbyid(r.id.profile_fragment_progress_bar);       profileheaderrl = (relativelayout) inflater.inflate(r.layout.profile_header_layout, container, false);     contactinforl = (relativelayout) inflater.inflate(r.layout.profile_contact_info_layout, container, false);     addressrl = (relativelayout) inflater.inflate(r.layout.profile_address_layout, container, false);     listinginforl = (relativelayout) inflater.inflate(r.layout.profile_listing_info_layout, container, false);     logoutrl = (relativelayout) inflater.inflate(r.layout.profile_logout_layout, container, false);      switch (profilemode) {         case agent_mode:             mergeadapter.addview(profileheaderrl);             mergeadapter.addview(contactinforl);             mergeadapter.addview(addressrl);             mergeadapter.addview(logoutrl);              break;         case search_mode:             mergeadapter.addview(profileheaderrl);             mergeadapter.addview(contactinforl);             mergeadapter.addview(addressrl);              break;         case listing_mode:             mergeadapter.addview(profileheaderrl);             mergeadapter.addview(addressrl);             mergeadapter.addview(listinginforl);             break;     }        profileiv = (roundedimageview) profileheaderrl.findviewbyid(r.id.profile_image_view);     emailiv = (imageview) contactinforl.findviewbyid(r.id.profile_email_icon);     phoneiv = (imageview) contactinforl.findviewbyid(r.id.profile_phone_icon);     initialstv = (textview) profileheaderrl.findviewbyid(r.id.profile_initials_tv);     nametv = (textview) profileheaderrl.findviewbyid(r.id.profile_name_tv);     brokeragetv = (textview) profileheaderrl.findviewbyid(r.id.profile_brokerage_tv);      officerl = (relativelayout) addressrl.findviewbyid(r.id.profile_office_rv);      emailaddresstv = (textview) contactinforl.findviewbyid(r.id.profile_email_tv);     phonenumbertv = (textview) contactinforl.findviewbyid(r.id.profile_phone_number_tv);     addresstv = (textview) addressrl.findviewbyid(r.id.profile_address_tv);     citystatetv = (textview) addressrl.findviewbyid(r.id.profile_city_state_tv);     ziptv = (textview) addressrl.findviewbyid(r.id.profile_zip_tv);     officetv = (textview) addressrl.findviewbyid(r.id.profile_office_tv);     donetv = (textview) profileheaderrl.findviewbyid(r.id.profile_done_tv);     edittv = (textview) profileheaderrl.findviewbyid(r.id.profile_edit_tv);     logoutbutton = (button) logoutrl.findviewbyid(r.id.profile_logout_button);      pricetv = (textview) listinginforl.findviewbyid(r.id.profile_listing_info_price_tv);     pricesqfttv = (textview) listinginforl.findviewbyid(r.id.profile_listing_info_pricesqft_tv);     bedstv = (textview) listinginforl.findviewbyid(r.id.profile_listing_info_beds_tv);     bathstv = (textview) listinginforl.findviewbyid(r.id.profile_listing_info_baths_tv);     sqfttv = (textview) listinginforl.findviewbyid(r.id.profile_listing_info_sqft_tv);     lotsizetv = (textview) listinginforl.findviewbyid(r.id.profile_listing_info_lot_size_tv);     yeartv = (textview) listinginforl.findviewbyid(r.id.profile_listing_info_years_tv);     floorstv = (textview) listinginforl.findviewbyid(r.id.profile_listing_info_stories_tv);  }  public void setviews() {      switch (profilemode) {         case agent_mode:             setagentviews();             setemailandphoneactions();             break;          case search_mode:             setsearchviews();             setemailandphoneactions();             break;          case listing_mode:             setlistingviews();             break;     }      nametv.settext(hsprofiledata.getfirstname() + " " + hsprofiledata.getlastname());     initialstv.settext(profiledataformatter.getinitials(hsprofiledata.getfirstname() + " " + hsprofiledata.getlastname()));      homestoryapplication.getinstance().getpicasso(getactivity()).             load(hsapicontroller.getinstance().getclientprofileimageurl(profileid))             .fit()             .centercrop()             .into(profileiv, new callback.emptycallback() {                 public void onsuccess() {                     initialstv.setvisibility(view.gone);                 }             });      donetv.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view) {             getactivity().onbackpressed();         }     });      edittv.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view) {             switch (profilemode) {                 case agent_mode:                     intent editagentprofileintent = new intent(getactivity(), addnewsearchactivity.class);                     editagentprofileintent.putextra(profile_id, profileid);                     editagentprofileintent.putextra(profile_mode, agent_mode);                     startactivity(editagentprofileintent);                     break;                 case search_mode:                     intent editsearchintent = new intent(getactivity(), addnewsearchactivity.class);                     editsearchintent.putextra(profile_id, profileid);                     editsearchintent.putextra(profile_mode, search_mode);                     startactivity(editsearchintent);                     break;                 case listing_mode:                     intent editlistingintent = new intent(getactivity(), addnewlistingactivity.class);                     editlistingintent.putextra(addnewlistingactivity.extra_profile_id, listing.getprofileid());                     startactivity(editlistingintent);                     break;             }         }     });  } 

update: commonsware showed me how fix issue. needed pass in listview container views adding merge adapter. , move code on onviewcreated,

here updated code:

    public void onviewcreated(view view, bundle savedinstancestate) {     super.onviewcreated(view, savedinstancestate);      listview listview = getlistview();      initviews(listview, view);      setviews();      setlistadapter(mergeadapter); } 

and initviews gets layoutinflater host activity.

    public void initviews(viewgroup container, view v) {      layoutinflater inflater = getactivity().getlayoutinflater(); .... 

thanks help!

in initviews(), need second parameter inflate() calls listview. that's not have -- passing in container fragment placed. change initviews() use listview in inflate() calls, , should have better results.

though honest, if correct in interpretation of code, expecting crash in android environment, not genymotion emulator.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

android - MPAndroidChart - How to add Annotations or images to the chart -