问题描述
我做在Android 2.3.3的一个小游戏,我想用openGLES。我的问题是,我可以的 GLSurfaceView 和的TextView 按钮在相同的布局。我的布局xml文件是以下
I'm doing a small game on Android 2.3.3 and I want to use openGLES. My question is whether I can GLSurfaceView and TextView, Button in the same layout. My layout xml file is as the following
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_horizontal" >
<com.ecnu.sei.manuzhang.nim.GameView
android:id="@+id/game_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="20dip"
android:layout_weight="1"
/>
<TextView
android:id="@+id/info_turn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginBottom="10dip"
/>
<Button
android:id="@+id/next_turn"
android:text="@string/button_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
/>
在 GameView延伸GLSurfaceView
会有误差 java.lang.NoSuchMethodException:GameView(上下文,AttributeSet中)
,但 GameView延伸GLSurfaceView
就行了。结果
如果没有,有没有把那些小部件一起的方法吗?结果
THX提前
When GameView extends GLSurfaceView
there will be errors java.lang.NoSuchMethodException: GameView(Context,AttributeSet)
but GameView extends GLSurfaceView
will do.
If not, is there a way to put those widgets together?
Thx in advance
推荐答案
在延长查看
或在这种情况下, GLSurfaceView
您可能需要将正确的构造函数。
When extending View
or in this case GLSurfaceView
you might need to place the correct constructor.
在你的情况你缺少这一个:
In your case you are missing this one:
public GameView(Context context, AttributeSet attrs)
您可以检查它是如何内部完成的 Cocos2dxGLSurfaceView 。
You can check how it's done inside cocos2d-x with the Cocos2dxGLSurfaceView.
这篇关于我怎样才能在LinearLayout中一起使用GLSurfaceView与其他视图,如TextView的或按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!