`
liangoogle
  • 浏览: 273298 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

在一个按钮正下方显示一个popwindow

阅读更多

 //这是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);

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics