复制代码 代码如下:
<SPAN style="FONT-SIZE: 18px">private void alertScreenDialog() {
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
String optStr = "手机屏幕分辨率为: "+dm.widthPixels+" x "+dm.heightPixels;
Builder builder = new Builder(this);
builder.setMessage(optStr);
builder.setIcon(R.drawable.firefox);
builder.setTitle("获取屏幕像素");
//点击确定按钮
builder.setPositiveButton("确定", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(GetScreenActivity.this, "获取到像素", Toast.LENGTH_LONG).show();
}
});
builder.setNegativeButton("返回", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(GetScreenActivity.this, "返回", Toast.LENGTH_LONG).show();
}
});
builder.create().show();
}</SPAN>