Wrox Programmer Forums
| 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 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 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!




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





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