public
class
testbubbleactivity
extends
activity {
/** 全局屏幕的高和宽 */
private
static
int
screen_width =
0
;
private
static
int
screen_height =
0
;
/**气泡显示的详细内容*/
private
textview tvbubcontent =
null
;
/**显示 我知道了 的提示*/
private
textview tvknow =
null
;
/**气泡view 里面包含2个textview*/
private
view bubbleview =
null
;
/**气泡dialog*/
private
dialog bubblealert =
null
;
public
void
oncreate(bundle savedinstancestate) {
super
.oncreate(savedinstancestate);
setcontentview(r.layout.main);
getdimension();
bubbleview = getlayoutinflater().inflate(r.layout.overlay_pop,
null
);
tvknow = (textview)bubbleview.findviewbyid(r.id.bubble_btn);
tvknow.settext(html.fromhtml(
"<u>"
+
"我知道了"
+
"</u>"
));
tvbubcontent = (textview)bubbleview.findviewbyid(r.id.bubble_text);
tvbubcontent.settext(
"上次程序异常退出,正在传输历史数据..."
);
tvknow.setonclicklistener(
new
view.onclicklistener(){
@override
public
void
onclick(view v) {
bubblealert.cancel();
}
});
int
tmpwidth = screen_width/
5
*
3
;
int
tmpheight =screen_height/
8
;
tvknow.setminwidth(tmpwidth);
tvbubcontent.setmaxwidth(tmpwidth);
bubblealert =
new
dialog(
this
,r.style.bubble_dialog);
window win = bubblealert.getwindow();
layoutparams params = win.getattributes();
params.x = -(screen_width/
8
);
params.y = -tmpheight;
params.width = tmpwidth;
win.setattributes(params);
bubblealert.setcancelable(
false
);
bubblealert.setcontentview(bubbleview);
bubblealert.show();
}
/**
* 获取屏幕尺寸
*/
private
void
getdimension(){
/** 获取屏幕的宽和高 */
displaymetrics dm =
new
displaymetrics();
getwindowmanager().getdefaultdisplay().getmetrics(dm);
screen_width = dm.widthpixels;
screen_height = dm.heightpixels;
}
}
发表评论