Вроде ничего криминального не делал. Создался лэйоут по умолчканию. На него положил ImageView. Создал класс TouchView.
package com.example.touchview;
import android.content.Context;
import android.view.SurfaceView;
public class TouchView extends SurfaceView{
public TouchView(Context context) {
super(context);
}
}
Добавил на лэйоут описание объекта
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rlMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".BlockerActivity" >
<com.example.lookatme.TouchView
android:id="@+id/tvPaint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/ivCenter"
android:layout_marginTop="14dp" />
<ImageView
android:id="@+id/ivCenter"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_launcher" android:contentDescription="TODO"/>
</RelativeLayout>
так приложение рушится на момент setContentView(R.layout.activity_brocker) . В LogCat ничего вразумительного:
10-23 18:02:03.442: W/dalvikvm(1964): threadid=1: thread exiting with uncaught exception (group=0xb57ef4f0)
10-23 18:02:03.442: E/AndroidRuntime(1964): FATAL EXCEPTION: main
10-23 18:02:03.442: E/AndroidRuntime(1964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.lookatme/com.example.lookatme.BlockerActivity}: java.lang.ClassCastException: android.view.SurfaceView
10-23 18:02:03.442: E/AndroidRuntime(1964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-23 18:02:03.442: E/AndroidRuntime(1964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-23 18:02:03.442: E/AndroidRuntime(1964): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-23 18:02:03.442: E/AndroidRuntime(1964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-23 18:02:03.442: E/AndroidRuntime(1964): at android.os.Handler.dispatchMessage(Handler.java:99)
10-23 18:02:03.442: E/AndroidRuntime(1964): at android.os.Looper.loop(Looper.java:130)
10-23 18:02:03.442: E/AndroidRuntime(1964): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-23 18:02:03.442: E/AndroidRuntime(1964): at java.lang.reflect.Method.invokeNative(Native Method)
10-23 18:02:03.442: E/AndroidRuntime(1964): at java.lang.reflect.Method.invoke(Method.java:507)
10-23 18:02:03.442: E/AndroidRuntime(1964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-23 18:02:03.442: E/AndroidRuntime(1964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-23 18:02:03.442: E/AndroidRuntime(1964): at dalvik.system.NativeStart.main(Native Method)
10-23 18:02:03.442: E/AndroidRuntime(1964): Caused by: java.lang.ClassCastException: android.view.SurfaceView
10-23 18:02:03.442: E/AndroidRuntime(1964): at com.example.lookatme.BlockerActivity.onCreate(BlockerActivity.java:67)
10-23 18:02:03.442: E/AndroidRuntime(1964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-23 18:02:03.442: E/AndroidRuntime(1964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-23 18:02:03.442: E/AndroidRuntime(1964): ... 11 more
10-23 18:04:01.741: W/ActivityThread(2020): Application com.example.lookatme is waiting for the debugger on port 8100...
что за причина такого падения? что делаю не так?
Без TouchView в лэйоуте все запускается отлично.