//这是show一个PopupWindow
PopupWindow mPopupWindow;
public void showPopupWindow() {
LayoutInflater mLayoutInflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
View music_popunwindwow = mLayoutInflater.inflate(R.layout.portal_select_layout, null);
ListView portal_select_listView = (ListView) music_popunwindwow.findViewById(R.id.portal_select_listView);
ArrayList androi = new ArrayList();
for (int i = 0; i < 10; i++) {
androi.add(""+i);}
portal_select_listView.setAdapter( new ArrayAdapter(this,android.R.layout.simple_spinner_dropdown_item,androi));
//popwindow的宽度和按钮的宽度相同都是230
mPopupWindow = new PopupWindow(music_popunwindwow,230, LayoutParams.WRAP_CONTENT);
mPopupWindow.setFocusable(true);
mPopupWindow.setOutsideTouchable(true);
mPopupWindow.update();
//位置在R.id.button的正下方
mPopupWindow.showAsDropDown(findViewById(R.id.button), 0,5);
}