我的应用程序中有一个TextView可以正常工作,直到我暂停该应用程序(按Home)并再次启动它。 它应该只是恢复活动,但是由于某种原因,TextView在恢复活动后不能正确显示文本。 文本显示为黑色正方形,如下所示:
有谁知道如何解决这一问题?
编辑:这是我的代码:TextView是在具有GLSurfaceView(称为GameView)的布局xml中创建的,并且在该XML之上。 这是xml代码:
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="MainActivity" >
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/gv"
/>
android:layout_width="100dp"
android:layout_height="100dp"
android:textColor="@android:color/black"
android:id="@+id/tv" />
这是MainActivity类onCreate方法中的代码:
setContentView(R.layout.activity_main);
GameView gameView = (GameView) findViewById(R.id.gv);
TextView textView = (TextView) findViewById(R.id.tv);
onPause,onResume,onStart,onStop方法与TextView没有任何关系。 将TextView保存到MainActivity的实例变量中,然后再调用TextView.setText()来设置TextView的文本。
编辑:我能够通过注释掉一行来解决此问题:被称为onPause()的GLES20.glDeleteTextures(...)我不知道这是怎么关联的或为什么调用此函数会导致该问题,但是何时我评论说问题消失了,当我把这条线重新拉回时,问题又随之而来。 如果任何人都能解释一个人与另一个人的关系,将不胜感激。