[blackberry]代码库
//在任何一个点击监听里写
public void showPopupWindow(String name){
//找到popupWindow自定义的布局
View popView = View.inflate(MainActivity.this, R.layout.pop_window, null);
TextView pop_tv = (TextView) popView.findViewById(R.id.pop_tv);
TextView nage_tv = (TextView) popView.findViewById(R.id.nage_tv);
TextView posi_tv = (TextView) popView.findViewById(R.id.posi_tv);
//给控件赋值
pop_tv.setText(name);
//new一个popupWindow,并且设置背景、点击外部是否dismiss、设置焦点、show进行展示
final PopupWindow popupWindow = new PopupWindow(popView, 300, 300);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
popupWindow.setOutsideTouchable(false);//点击其他地方可以disimis
popupWindow.setFocusable(true);//设置焦点可获取焦点
popupWindow.showAtLocation(popView, Gravity.CENTER,0,0);//showAsDropDown(view);
//控件监听进行dismiss
posi_tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
popupWindow.dismiss();
}
});
}
by: 发表于:2017-10-25 10:46:13 顶(0) | 踩(0) 回复
??
回复评论