Good day for all programmers. I have a problem NullPointerException when i call the method showAtLocation of PopupWindow. As in many forums was written, this exception happens because first parameter of method showAtLocation is null. So i check it this way:
showAtLocation (View parent, int gravity, int x, int y)
parent.equals(null) //- it returns false 
LinearLayout lout = (LinearLayout) parent; 
lout.getChildCount() //- it returns true count of child elements 
((TextView) lout.getChildAt(1)).getText() //- it returns a text which i write in android:text field
I have a Gridview and its adapter is CustomAdapter (extends BaseAdapter). In this class (CustomAdapter) has OnClickListener in getView method. I want to set popupwindow for each item of this gridview. So in OnClickListener i call a method showPopup:
private void showPopup(final Activity context, Point p) {
   int popupWidth = 200;
   int popupHeight = 150;
   // Inflate the 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, i need your help
