SurfaceView 클래스의 하위 클래스를 만들어 내 자신의보기를 만들었습니다.xml 레이아웃의 사용자 정의보기
그러나 xml 레이아웃 파일에서 추가하는 방법을 알 수 없습니다. 현재 main.xml은 다음과 같습니다 :
<?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"
>
<View
class="com.chainparticles.ChainView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
내가 무엇을 놓쳤습니까?
편집
더 많은 정보
내보기이
package com.chainparticles;
public class ChainView extends SurfaceView implements SurfaceHolder.Callback {
public ChainView(Context context) {
super(context);
getHolder().addCallback(this);
}
// Other stuff
}
처럼 보인다 그리고 그것은 다음과 같이 작동합니다 :
ChainView cview = new ChainView(this);
setContentView(cview);
을하지만에서 사용하려고 할 때 아무 일도 발생하지 않습니다 the XML.
내 첫 번째 레이아웃에서 방금 검은 화면이 나타났습니다. 대신이 앱이 충돌합니다. – monoceres
스택 추적은 무엇입니까? – Qberticus
http://pastebin.com/u2t3jdMt – monoceres