java.lang.ClassCastException: android.widget.AbsListView$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams -
i trying put message n date below in same bubble messeage textview. used layoutparams make bubble left or right.
but i'm getting error.
fatal exception: main process: com.rana.sahaj.myyu, pid: 18103 java.lang.classcastexception: android.widget.abslistview$layoutparams cannot cast android.widget.linearlayout$layoutparams @ com.rana.sahaj.myyu.singlemessageroomactivity$messagesadapter.getview(singlemessageroomactivity.java:326) @ android.widget.abslistview.obtainview(abslistview.java:2257) @ android.widget.listview.makeandaddview(listview.java:1790) @ android.widget.listview.filldown(listview.java:691) @ android.widget.listview.fillfromtop(listview.java:752) @ android.widget.listview.layoutchildren(listview.java:1616) @ android.widget.abslistview.onlayout(abslistview.java:2089) @ android.view.view.layout(view.java:14828) @ android.view.viewgroup.layout(viewgroup.java:4631) @ android.widget.linearlayout.setchildframe(linearlayout.java:1671) @ android.widget.linearlayout.layoutvertical(linearlayout.java:1525) @ android.widget.linearlayout.onlayout(linearlayout.java:1434) @ android.view.view.layout(view.java:14828) @ android.view.viewgroup.layout(viewgroup.java:4631) @ android.widget.framelayout.layoutchildren(framelayout.java:453) @ android.widget.framelayout.onlayout(framelayout.java:388) @ android.view.view.layout(view.java:14828) @ android.view.viewgroup.layout(viewgroup.java:4631) @ android.widget.linearlayout.setchildframe(linearlayout.java:1671) @ android.widget.linearlayout.layoutvertical(linearlayout.java:1525) @ android.widget.linearlayout.onlayout(linearlayout.java:1434) @ android.view.view.layout(view.java:14828) @ android.view.viewgroup.layout(viewgroup.java:4631) @ android.widget.framelayout.layoutchildren(framelayout.java:453) @ android.widget.framelayout.onlayout(framelayout.java:388) @ android.view.view.layout(view.java:14828) @ android.view.viewgroup.layout(viewgroup.java:4631) @ android.widget.linearlayout.setchildframe(linearlayout.java:1671) @ android.widget.linearlayout.layoutvertical(linearlayout.java:1525) @ android.widget.linearlayout.onlayout(linearlayout.java:1434) @ android.view.view.layout(view.java:14828) @ android.view.viewgroup.layout(viewgroup.java:4631) @ android.widget.framelayout.layoutchildren(framelayout.java:453) @ android.widget.framelayout.onlayout(framelayout.java:388) @ android.view.view.layout(view.java:14828) @ android.view.viewgroup.layout(viewgroup.java:4631) @ android.view.viewrootimpl.performlayout(viewrootimpl.java:2026) @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1783) @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1039) @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:5648) @ android.view.choreographer$callbackrecord.run(choreographer.java:761) @ android.view.choreographer.docallbacks(choreographer.java:574) @ android.view.choreographer.doframe(choreographer.java:544) @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:747) @ android.os.handler.handlecallback(handler.java:733) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:136) @ android.app.activitythread.main(activitythread.java:5052) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:515) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:609) @ dalvik.system.nativestart.main(native method)
the getview() of singlemessageroom activity.
@override public view getview(int position, view view, viewgroup parent) { layoutinflater layoutinflater = (layoutinflater) getcontext().getsystemservice(context.layout_inflater_service); view convertview; if(view == null){ convertview = layoutinflater.inflate(r.layout.message, parent, false); } else { convertview = view; } message message = getitem(position); textview nameview = (textview)convertview.findviewbyid(r.id.message); nameview.settext(message.gettext()); textview timeview=(textview)convertview.findviewbyid(r.id.timemessage); timeview.settext(message.gettime()); linearlayout mlinearlayout=(linearlayout)convertview.findviewbyid(r.id.layoutbubble); linearlayout.layoutparams layoutparams = (linearlayout.layoutparams)mlinearlayout.getlayoutparams(); int sdk = build.version.sdk_int; if (message.getsender().equals(emailpref)){ if (sdk >= build.version_codes.jelly_bean) { mlinearlayout.setbackground(this.getcontext().getresources().getdrawable(r.drawable.mybubbleown2)); nameview.settextcolor(this.getcontext().getresources().getcolor(r.color.white)); } else{ mlinearlayout.setbackground(getdrawable(r.drawable.mybubbleown2)); nameview.settextcolor(this.getcontext().getresources().getcolor(r.color.white)); } layoutparams.gravity = gravity.right; }else{ if (sdk >= build.version_codes.jelly_bean) { mlinearlayout.setbackground(this.getcontext().getresources().getdrawable(r.drawable.myotherbubbleown2)); nameview.settextcolor(this.getcontext().getresources().getcolor(r.color.black)); } else{ mlinearlayout.setbackground(getdrawable(r.drawable.myotherbubbleown2)); nameview.settextcolor(this.getcontext().getresources().getcolor(r.color.black)); } layoutparams.gravity = gravity.left; } mlinearlayout.setlayoutparams(layoutparams); return convertview; }
Comments
Post a Comment