ポップアップウィンドウとpopupViewおよびレイアウトインフレータを宣言します。
private PopupWindow pw;
private View popupView;
private LayoutInflater inflater;
oncreateメソッドで、ポップアップとして表示するレイアウトを膨らませます。
inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
popupView = inflater.inflate(R.layout.popup_layout, null, false);
これがonclickメソッドになります。
public void newUserInput(View view){
pw.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
pw.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
pw.setOutsideTouchable(false);
pw.setContentView(popupView);
// Use any one method - showAtLocation or showAsDropDown to show the popup
pw.showAtLocation(parent, gravity, x, y);
pw.showAsDropDown(anchor, xoff, yoff)
}