Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2
This is the forum to discuss the Wrox book Professional Android Application Development by Reto Meier; ISBN: 9780470344712
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 11th, 2010, 07:05 PM
Registered User
 
Join Date: Jul 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 4 Compass

I am having trouble inflating my view from XML.

This is my main.xml file
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <jason.android.compass.CompassView
    	android:id="@+id/compassView"
    	android:layout_width="fill_parent"
    	android:layout_height="fill_parent"
	/>
</LinearLayout>
And here i'm trying to use it...

Code:
package jason.android.compass;

import android.app.Activity;
import android.os.Bundle;

public class CompassExample extends Activity {
	
	//private CompassView compassView;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.main);
        CompassView compassView = (CompassView)this.findViewById(R.id.compassView);
        //compassView.setBearing(50);
    }
}
It works as long as I don't access the compassView object (to set the bearing in this case). If I try to use the setBearing method, the application crashes.

And finally, if I don't load from a resource, it works just fine (example below).

Code:
package jason.android.compass;

import android.app.Activity;
import android.os.Bundle;

public class CompassExample extends Activity {
	
	//private CompassView compassView;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        CompassView cv = new CompassView(this);
        setContentView(cv);
        cv.setBearing(50);
    }
}
I appreciate the help!
Reply With Quote
Reply


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
Chapter 10: Compass Omen_20 BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 0 April 7th, 2010 07:42 PM
Chapter 10: Compass Omen_20 BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 0 April 7th, 2010 07:13 PM
Chapter 6 - Code Download Missing for this Chapter dbaechtel BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 August 11th, 2009 11:02 AM
Chapter 4 Compass background color eags BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 1 January 10th, 2009 01:07 PM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM



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


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