0
我的問題很簡單。我有擴展GLSurfaceView類的TouchSurfaceView。我希望創建活動,其中三個TextViews和Button位於底部,TouchSurfaceView位於頂部,但我不知道如何在XML佈局中讀取它。如何放入擴展GLSurfaceView的LinearLayout類?
我的問題很簡單。我有擴展GLSurfaceView類的TouchSurfaceView。我希望創建活動,其中三個TextViews和Button位於底部,TouchSurfaceView位於頂部,但我不知道如何在XML佈局中讀取它。如何放入擴展GLSurfaceView的LinearLayout類?
你剛纔提到它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
}
謝謝,但我正好試試這個...我的包是cz.audiorecenze所以我儘量'
west44
2011-06-05 08:53:19
@ west44很難說更多沒有任何代碼看到,但可能的原因是缺乏正確的構造函數。請參閱上面的更新迴應。 – Aleadam 2011-06-05 15:56:12
是的,你是對的。這個問題出現在具有兩個參數(上下文,AttributeSet)的構造函數中,而我只爲(上下文)構造函數。感謝幫助 ;) – west44 2011-06-05 20:32:53