主类
- package sucre.android;
-
- import android.app.Activity;
- import android.os.Bundle;
- import android.util.DisplayMetrics;
- import android.widget.TextView;
-
-
-
-
-
- public class EXT03_05 extends Activity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- DisplayMetrics dm = new DisplayMetrics();
-
-
-
- getWindowManager().getDefaultDisplay().getMetrics(dm);
-
- String str = "手机屏幕的分辨率为:"+dm.widthPixels+"x"+dm.heightPixels;
-
- TextView tv = (TextView)findViewById(R.id.myTextView);
-
- tv.setText(str);
- }
- }
本文转自sucre03 51CTO博客,原文链接:http://blog.51cto.com/sucre/742952,如需转载请自行联系原作者