android popupwindow - NullPointErexception when calling showAtLocation -


good day programmers. have problem nullpointerexception when call method showatlocation of popupwindow. in many forums written, exception happens because first parameter of method showatlocation null. check way:

showatlocation (view parent, int gravity, int x, int y) parent.equals(null) //- returns false  linearlayout lout = (linearlayout) parent;  lout.getchildcount() //- returns true count of child elements  ((textview) lout.getchildat(1)).gettext() //- returns text write in android:text field 

i have gridview , adapter customadapter (extends baseadapter). in class (customadapter) has onclicklistener in getview method. want set popupwindow each item of gridview. in onclicklistener call method showpopup:

private void showpopup(final activity context, point p) {    int popupwidth = 200;    int popupheight = 150;     // inflate popup_layout.xml    linearlayout viewgroup = (linearlayout) context.findviewbyid(r.id.popup);    layoutinflater layoutinflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service);    //layoutinflater layoutinflater = prnt.getlayoutinflater();    view parent = layoutinflater.inflate(r.layout.popup_layout, viewgroup);     final popupwindow popup = new popupwindow(context);    popup.setcontentview(parent);    popup.setwidth(popupwidth);    popup.setheight(popupheight);    popup.setfocusable(true);     int offset_x = 30;    int offset_y = 30;     popup.setbackgrounddrawable(new bitmapdrawable());     /*    linearlayout lout = (linearlayout) parent;    showmsg(parent.equals(null) + " : type " + lout.getchildcount() + " - " + ((textview) lout.getchildat(1)).gettext());    */    popup.showatlocation(parent, 0, p.x + offset_x, p.y + offset_y); //error        occurs here } 

please, need help

02-10 13:49:34.148 2376-2376/com.iyb.wi.mobi i/art: not late-enabling -xcheck:jni (already on) 02-10 13:49:34.255 2376-2376/com.iyb.wi.mobi w/system: classloader referenced unknown path: /data/app/com.iyb.wi.mobi-2/lib/x86 02-10 13:49:34.331 2376-2376/com.iyb.wi.mobi i/gmpm: app measurement starting up, version: 8487 02-10 13:49:34.331 2376-2376/com.iyb.wi.mobi i/gmpm: enable debug logging run: adb shell setprop log.tag.gmpm verbose 02-10 13:49:34.501 2376-2392/com.iyb.wi.mobi d/openglrenderer: use egl_swap_behavior_preserved: true 02-10 13:49:34.582 2376-2392/com.iyb.wi.mobi i/openglrenderer: initialized egl, version 1.4 02-10 13:49:34.639 2376-2392/com.iyb.wi.mobi w/egl_emulation: eglsurfaceattrib not implemented 02-10 13:49:34.639 2376-2392/com.iyb.wi.mobi w/openglrenderer: failed set egl_swap_behavior on surface 0xad6dfbc0, error=egl_success 02-10 13:49:45.041 2376-2390/com.iyb.wi.mobi i/gmpm: tag manager not found , not used 02-10 13:50:05.590 2376-2386/com.iyb.wi.mobi i/art: background sticky concurrent mark sweep gc freed 11567(906kb) allocspace objects, 10(200kb) los     objects, 22% free, 2mb/3mb, paused 25.010ms total 151.250ms 02-10 13:50:05.670 2376-2392/com.iyb.wi.mobi w/egl_emulation: eglsurfaceattrib not implemented 02-10 13:50:05.670 2376-2392/com.iyb.wi.mobi w/openglrenderer: failed set egl_swap_behavior on surface 0xad6e5d00, error=egl_success 02-10 13:50:08.094 2376-2376/com.iyb.wi.mobi i/choreographer: skipped 141 frames!  application may doing work on main thread. 02-10 13:50:08.165 2376-2392/com.iyb.wi.mobi e/surface: getslotfrombufferlocked: unknown buffer: 0xab793b90 02-10 13:50:34.728 2376-2392/com.iyb.wi.mobi w/egl_emulation: eglsurfaceattrib not implemented 02-10 13:50:34.728 2376-2392/com.iyb.wi.mobi w/openglrenderer: failed set egl_swap_behavior on surface 0xa1c51100, error=egl_success 02-10 13:50:35.582 2376-2392/com.iyb.wi.mobi e/surface: getslotfrombufferlocked: unknown buffer: 0xab793c00 02-10 13:50:35.885 2376-2392/com.iyb.wi.mobi w/egl_emulation: eglsurfaceattrib not implemented 02-10 13:50:35.885 2376-2392/com.iyb.wi.mobi w/openglrenderer: failed set egl_swap_behavior on surface 0xa1c51d00, error=egl_success 02-10 13:50:38.395 2376-2392/com.iyb.wi.mobi e/surface: getslotfrombufferlocked: unknown buffer: 0xab793c70 02-10 13:50:45.007 2376-2392/com.iyb.wi.mobi w/egl_emulation: eglsurfaceattrib not implemented 02-10 13:50:45.007 2376-2392/com.iyb.wi.mobi w/openglrenderer: failed set egl_swap_behavior on surface 0xa17bad20, error=egl_success 02-10 13:50:45.947 2376-2392/com.iyb.wi.mobi e/surface: getslotfrombufferlocked: unknown buffer: 0xb3fd6830 02-10 13:50:46.023 2376-2386/com.iyb.wi.mobi i/art: background sticky concurrent mark sweep gc freed 3519(315kb) allocspace objects, 2(40kb) los objects, 0% free, 4mb/4mb, paused 12.041ms total 40.080ms 02-10 13:50:50.583 2376-2376/com.iyb.wi.mobi d/androidruntime: shutting down vm 02-10 13:50:50.583 2376-2376/com.iyb.wi.mobi e/androidruntime: fatal exception: main                                                               process: com.iyb.wi.mobi, pid: 2376                                                               java.lang.nullpointerexception: attempt read field 'int android.graphics.point.x' on null object reference                                                                   @ com.iyb.wi.mobi.customadapter.showpopup(customadapter.java:136)                                                                   @ com.iyb.wi.mobi.customadapter.access$000(customadapter.java:23)                                                                   @ com.iyb.wi.mobi.customadapter$1.onclick(customadapter.java:84)                                                                   @ android.view.view.performclick(view.java:5198)                                                                   @ android.view.view$performclick.run(view.java:21147)                                                                   @ android.os.handler.handlecallback(handler.java:739)                                                                   @ android.os.handler.dispatchmessage(handler.java:95)                                                                   @ android.os.looper.loop(looper.java:148)                                                                   @ android.app.activitythread.main(activitythread.java:5417)                                                                   @ java.lang.reflect.method.invoke(native method)                                                                   @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726)                                                                   @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -