Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning Android Application Development
|
BOOK: Beginning Android Application Development
This is the forum to discuss the Wrox book Beginning Android Application Development by Wei-Meng Lee; ISBN: 978-1-1180-1711-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Android Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 6th, 2015, 02:23 PM
Registered User
 
Join Date: Jul 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation chapter 2 -getting error in fragmenttransaction.replace method

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);


FragmentTransaction fragmentTransaction =
getFragmentManager().beginTransaction();

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
fragmentTransaction.replace(
android.R.id.content, fragment1);
}else {
//---portrait mode---
Fragment2 fragment2 = new Fragment2();
fragmentTransaction.replace(
android.R.id.content, fragment2);
}
//---add to the back stack---
//fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();




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

Last edited by zeorox; July 8th, 2015 at 02:44 AM.. Reason: dynamically adding the fragment





Similar Threads
Thread Thread Starter Forum Replies Last Post
about chapter 7 requestLocationUpdates method stacychou BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 1 May 1st, 2009 10:52 AM
More Chapter 3 Method questions. wbrco BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 3 February 17th, 2009 12:14 AM
Replace Method in JavaScript kwilliams Javascript How-To 2 April 3rd, 2007 12:50 PM
Replace method don't work with [ ] / skyler Javascript How-To 1 December 30th, 2006 10:04 AM
String.replace() method JohnD Javascript 0 August 20th, 2004 06:46 AM





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