android - java.lang.NullPointerException in ArrayAdapter -
from google play "crash & anr" see users getting below error. couldn't reproduce error self. have arrayadaper class public class discussarrayadapter extends arrayadapter{ used listitem in activity:
first, don't know if proplem in arrayadaper class or in activity. least if advice should error. shell example focus on teh getview method of arrayadapter?
the getview method of arrayadaper below.
java.lang.nullpointerexception @ com.castvast.discussarrayadapter.getview(discussarrayadapter.java:84) @ android.widget.abslistview.obtainview(abslistview.java:2461) @ android.widget.listview.makeandaddview(listview.java:1775) @ android.widget.listview.fillup(listview.java:712) @ android.widget.listview.correcttoohigh(listview.java:1401) @ android.widget.listview.fillspecific(listview.java:1339) @ android.widget.listview.layoutchildren(listview.java:1618) @ android.widget.abslistview.onlayout(abslistview.java:2296) @ android.view.view.layout(view.java:14055) @ android.view.viewgroup.layout(viewgroup.java:4604) @ android.widget.linearlayout.setchildframe(linearlayout.java:1655) @ android.widget.linearlayout.layoutvertical(linearlayout.java:1513) @ android.widget.linearlayout.onlayout(linearlayout.java:1426) @ android.view.view.layout(view.java:14055) @ android.view.viewgroup.layout(viewgroup.java:4604) @ android.widget.framelayout.onlayout(framelayout.java:448) @ android.view.view.layout(view.java:14055) @ android.view.viewgroup.layout(viewgroup.java:4604) @ android.widget.linearlayout.setchildframe(linearlayout.java:1655) @ android.widget.linearlayout.layoutvertical(linearlayout.java:1513) @ android.widget.linearlayout.onlayout(linearlayout.java:1426) @ android.view.view.layout(view.java:14055) @ android.view.viewgroup.layout(viewgroup.java:4604) @ android.widget.framelayout.onlayout(framelayout.java:448) @ android.view.view.layout(view.java:14055) @ android.view.viewgroup.layout(viewgroup.java:4604) @ android.view.viewrootimpl.performlayout(viewrootimpl.java:1992) @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1813) @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1112) @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:4472) @ android.view.choreographer$callbackrecord.run(choreographer.java:725) @ android.view.choreographer.docallbacks(choreographer.java:555) @ android.view.choreographer.doframe(choreographer.java:525) @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:711) @ android.os.handler.handlecallback(handler.java:615) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:4898) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1006) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:773) @ dalvik.system.nativestart.main(native method)
get view method:
public view getview(int position, view convertview, viewgroup parent) { view row = convertview; if (row == null) { layoutinflater inflater = (layoutinflater) this.getcontext().getsystemservice(context.layout_inflater_service); row = inflater.inflate(r.layout.listitem_discuss, parent, false); } wrapper = (linearlayout) row.findviewbyid(r.id.wrapper); onemessage coment = getitem(position); myactivity.itempostin=position; imageview arrowimage = (imageview) row.findviewbyid(r.id.aquaplayicon); final imageview arrowimagefinal=arrowimage; final long seqf=coment.seq ; final string userlinkf=coment.userlink ; arrowimage.setonclicklistener(new onclicklistener(){ public void onclick(view view) { ; myactivity.opencontextmenu(arrowimagefinal); myactivity.seq=seqf; myactivity.userlink=userlinkf; ; }}); arrowimage.setonlongclicklistener(new onlongclicklistener(){ @override public boolean onlongclick(view v) { ; myactivity.opencontextmenu(arrowimagefinal); myactivity.seq=seqf; myactivity.userlink=userlinkf; return true; }}); myactivity .registerforcontextmenu(arrowimage); msgtextview =(textview)/*(edittext)*/ row.findviewbyid(r.id.comment); myactivity .registerforcontextmenu(msgtextview ); final textview mytextviewfinal=msgtextview; msgtextview.setonclicklistener(new onclicklistener(){ public void onclick(view view) { ; myactivity.opencontextmenu( mytextviewfinal); myactivity.seq=seqf; //copy funcation //cast received view textview can text textview yourtextview = (textview) view; activity host = (activity) yourtextview.getcontext(); //place textview's text in clipboard android.text.clipboardmanager clipboard = ( android.text.clipboardmanager) host.getsystemservice(host.clipboard_service ); clipboard.settext(yourtextview.gettext()); ; }}); msgtextview.setonlongclicklistener(new onlongclicklistener(){ @override public boolean onlongclick(view v) { ; myactivity.opencontextmenu( mytextviewfinal); myactivity.seq=seqf; //copy funcation //cast received view textview can text textview yourtextview = (textview) v; activity host = (activity) yourtextview.getcontext(); //place textview's text in clipboard android.text.clipboardmanager clipboard = ( android.text.clipboardmanager) host.getsystemservice(host.clipboard_service ); clipboard.settext(yourtextview.gettext()); return true; }}); msgtextview.settext(coment.msgtext); //msgtextview.setgravity(!coment.sentbyuser ? gravity.left : gravity.right) ; sender = (textview) row.findviewbyid(r.id.sender); prettytime p = new prettytime(); string device_lang= locale.getdefault().getlanguage();//getdisplaylanguage(); string dateformat=null; if(device_lang==null || !device_lang.equals("ar") ) { dateformat= p.format(new date( coment.msgdate.gettime() )); }else { //just display numric simpledateformat sdf = new simpledateformat("dd/mm/yyyy h:mm a", locale.getdefault() ); long duration =coment.msgdate.gettime(); dateformat=sdf.format(new date(duration /*- timezone.getdefault().getrawoffset()*/ )); } if(coment.sentbyuser) sender.settext(row.getcontext().getresources().getstring(r.string.sender_marker)+" @ "+dateformat ); else sender.settext(coment.sendername+" @ "+dateformat ); relativelayout.layoutparams params = new relativelayout.layoutparams(relativelayout.layoutparams.wrap_content, relativelayout.layoutparams.wrap_content); relativelayout.layoutparams params2 = new relativelayout.layoutparams(relativelayout.layoutparams.wrap_content, relativelayout.layoutparams.wrap_content); params.setmargins(5, 5, 5, 0); params2.setmargins(0, 0, 0, 0); if(!coment.sentbyuser) { params.addrule(relativelayout.align_parent_left, relativelayout.true); params2.addrule(relativelayout.align_parent_left, relativelayout.true); params2.addrule(relativelayout.below, msgtextview.getid()); // no need show arrow image arrowimage.setvisibility(view.visible); } else { params.addrule(relativelayout.align_parent_right, relativelayout.true); params2.addrule(relativelayout.align_parent_right, relativelayout.true); params2.addrule(relativelayout.below, msgtextview.getid()); arrowimage.setvisibility(view.gone); } msgtextview.setlayoutparams(params);//msgtextview.setpadding(10, 0, 10, 0); sender.setlayoutparams(params2);//sender.setpadding(10, 0, 10, 0); msgtextview.setbackgroundresource(!coment.sentbyuser ? r.drawable.bubble_yellow : r.drawable.bubble_green); wrapper.setgravity(!coment.sentbyuser ? gravity.left : gravity.right); return row; }
Comments
Post a Comment