Hi developer forum!
Disclaimer: I'm completely new to Android development, and my java is rusty. So bear with me. I'm Using Eclipse 3.5 on a mac.
I'm struggling to get any kind of subclassed view to work in my Android layout. What I'm trying to do, is to have a few TextViews and a subclassed SurfaceView side by side, defined in layout.xml. But the application simply crashes in the emulator when I substitute a real SurfaceView with my subclassed one.
I'm confused, because I believe I have done the same as other examples demonstrating subclassed views do...
1. My subclassed surfaceview, LarspPreview.java:
2. Excerpt from my main.xml layout:
Works:
Crashes: (android says in emulator: "... has stopped unexpectedly ...")
What am I missing? Its making me frustrated that I can't get this simple concept working!!
Thanks!
Disclaimer: I'm completely new to Android development, and my java is rusty. So bear with me. I'm Using Eclipse 3.5 on a mac.
I'm struggling to get any kind of subclassed view to work in my Android layout. What I'm trying to do, is to have a few TextViews and a subclassed SurfaceView side by side, defined in layout.xml. But the application simply crashes in the emulator when I substitute a real SurfaceView with my subclassed one.
I'm confused, because I believe I have done the same as other examples demonstrating subclassed views do...
1. My subclassed surfaceview, LarspPreview.java:
Code:
package com.example.larsp.testing;
import android.content.Context;
import android.view.SurfaceView;
public class LarspPreview extends SurfaceView
{
LarspPreview(Context context)
{
super(context);
}
}
Works:
Code:
<SurfaceView
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
Code:
<com.example.larsp.testing.LarspPreview
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
Thanks!

