2013.10.9 Difference between Activity and FragmentActivity, getMetrics

2025 ワード

1,

Difference between Activity and FragmentActivity


FragmentActivity  is a subclass of  Activity  that was built for the Android Support Package.
The  FragmentActivity  class adds a couple new methods to ensure compatibility with older versions of Android, but other than that, there really isn't much of a difference between the two. Just make sure you change all calls to  getLoaderManager()  and  getFragmentManager()  to  getSupportLoaderManager()  and getSupportFragmentManager()  respectively.
link:  http://stackoverflow.com/questions/10477997/difference-between-activity-and-fragmentactivity
まとめ:android 3.0(api 11)以前のプラットフォームでFragmentを使用するには、パッケージsupportが必要です.v 4,この場合はFragmentActivity,getSupportFragmentManager(),Fragment,ともにsupport.v 4の下です.
3.0以上のプラットフォームでActivityを直接使用し、
getFragmentManager()、Fragment、androidを使用しています.app.Fragment
2,
		DisplayMetrics dm = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(dm);
2行目のコードはdmに多くの属性を設定することができ、getMetricsのソースコードはこのようなものである.
129    public void getMetrics(DisplayMetrics outMetrics) {
130        outMetrics.widthPixels  = getWidth();
131        outMetrics.heightPixels = getHeight();
132        outMetrics.density      = mDensity;
133        outMetrics.densityDpi   = (int)((mDensity*DisplayMetrics.DENSITY_DEFAULT)+.5f);
134        outMetrics.scaledDensity= outMetrics.density;
135        outMetrics.xdpi         = mDpiX;
136        outMetrics.ydpi         = mDpiY;
137    }
  DisplayMetrics public dm 。  
  DisplayMetrics 。