2011-06-04 34 views

回答

0

你剛纔提到它usingthe全名(包括包),就好像它是任何其他VEW:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    > 
    <your.package.TouchSurfaceView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="text" 
     /> 
<!-- etcetera --> 
</LinearLayout> 

你需要一個構造函數的AttributeSet作爲參數(充氣XML時使用):

public TouchSurfaceView(Context context, AttributeSet attr) { 
    super(context, attr); 
    // the rest of your code 
} 
+0

謝謝,但我正好試試這個...我的包是cz.audiorecenze所以我儘量' west44 2011-06-05 08:53:19

+0

@ west44很難說更多沒有任何代碼看到,但可能的原因是缺乏正確的構造函數。請參閱上面的更新迴應。 – Aleadam 2011-06-05 15:56:12

+0

是的,你是對的。這個問題出現在具有兩個參數(上下文,AttributeSet)的構造函數中,而我只爲(上下文)構造函數。感謝幫助 ;) – west44 2011-06-05 20:32:53