Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning Android Application Development
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 6th, 2015, 02:23 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
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) {

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

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 04:43 PM.

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