p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Android Application Development (http://p2p.wrox.com/forumdisplay.php?f=631)
-   -   chapter 2 -getting error in fragmenttransaction.replace method (http://p2p.wrox.com/showthread.php?t=94682)

zeorox July 6th, 2015 02:23 PM

chapter 2 -getting error in fragmenttransaction.replace method
public void onCreate(Bundle savedInstanceState) {

FragmentTransaction fragmentTransaction =

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics( metrics);

if (metrics.widthPixels > metrics.heightPixels)
//---landscape mode---
Fragment1 fragment1 = new Fragment1() ;
// android.R.id.content refers to the content
// view of the activity
android.R.id.content, fragment1);
}else {
//---portrait mode---
Fragment2 fragment2 = new Fragment2();
android.R.id.content, fragment2);
//---add to the back stack---

getting error in the replace method
-The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, Fragment1)

i replaced display class getWidth(),and getHeight() with DisplayMetrics class due to dreprication (hoping after the solution for the replace it will work,havnt checked it somewhere else)

helpp fast

All times are GMT -4. The time now is 07:14 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.