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!