我写了一个fragment的demo,在android 3.0下,该方法getWidth()
和getHeigh()
已弃用。我读了api,发现这getSize(point)
两种方法是一样的,所以我试试。
Display d = wm.getDefaultDisplay();
int width=0;
int height=0;
Point point = new Point(width,height);
d.getRealSize(point);
但是当我运行应用程序时,出现错误,有没有人发现这样的问题?:
02-01 03:13:06.548: E/AndroidRuntime(558): FATAL EXCEPTION: main
02-01 03:13:06.548: E/AndroidRuntime(558): java.lang.NoSuchMethodError: android.view.Display.getRealSize
02-01 03:13:06.548: E/AndroidRuntime(558): at com.demo.fragment.FragmentDemoActivity.onCreate(FragmentDemoActivity.java:33)
02-01 03:13:06.548: E/AndroidRuntime(558): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
02-01 03:13:06.548: E/AndroidRuntime(558): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)