復制代碼 代碼如下:
<SPAN >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>