0

私の質問は簡単です。GLSurfaceView を拡張するクラス TouchSurfaceView があります。3 つの TextViews と Button を下部に、TouchSurfaceView を上部に配置するアクティビティを作成したいのですが、これを XML レイアウトでどのように読み取るかわかりません。

4

1 に答える 1

0

他の 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
}
于 2011-06-05T04:38:44.587 に答える