You do not call setContentView(R.layout.myLayout) in your onCreate(Bundle) method. Name it right after super.onCreate(savedInstanceState); .
This is from the Activity resource page on the Android developers site:
There are two methods: almost all subclasses of Activity implementation:
onCreate (Bundle) is where you initialize your activity. Most importantly, here you usually call setContentView (int) using a layout resource that defines your user interface, and using findViewById (int) to get widgets in that user interface that you need to interact with programmatically.
onPause () is where you deal with a user leaving your activity. Most importantly, any changes made by the user should be at this stage (usually for a ContentProvider containing data).
Change 1:
Replace:
pwindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
with:
new Handler().postDelayed(new Runnable(){ public void run() { pwindow.showAtLocation(popupView, Gravity.CENTER, 0, 0); } }, 100L);
source share