在软件的开发之中,用户可以使用PopupWindow组件,在窗口上弹出一个小窗口以进行一些操作
-
private class OnClickListenerImpl implements OnClickListener { // 设置监听
-
@Override
-
public void onClick(View view) {
-
LayoutInflater inflater = LayoutInflater
-
.from(MyPopupWindowDemo.this);// 取得LayoutInflater对象
-
MyPopupWindowDemo.this.popView = inflater.inflate(
-
R.layout.popwindow, null); // 读取布局管理器
-
MyPopupWindowDemo.this.popWin = new PopupWindow(popView, 300, 220,
-
true); // 实例化PopupWindow
-
MyPopupWindowDemo.this.changestatus = (RadioGroup) popView
-
.findViewById(R.id.changestatus); // 取得组件
-
MyPopupWindowDemo.this.cancel = (Button) popView
-
.findViewById(R.id.cancel); // 取得组件
-
MyPopupWindowDemo.this.changestatus
-
.setOnCheckedChangeListener(
-
new OnCheckedChangeListenerImpl()); // 设置监听
-
MyPopupWindowDemo.this.cancel
-
.setOnClickListener(new OnClickListener() {
-
@Override
-
public void onClick(View v) { MyPopupWindowDemo.this.popWin.dismiss(); // 关闭弹出窗口
-
}
-
});
-
MyPopupWindowDemo.this.popWin.showAtLocation(
-
MyPopupWindowDemo.this.popbut,
-
Gravity.CENTER, 0, 0); // 显示弹出窗口
-
}
-
}
020718_弹出窗口:PopupWindow.ppt
阅读(1535) | 评论(0) | 转发(0) |