I have a TextView in my application that works fine until I pause the application (by pressing home) and launch it again. It should just resume the activity, but for some reason the TextView doesn't display the text properly after it resumes the activity. The text is showing up as black squares, like this:
https://i.sstatic.net/5mtvy.png
Does anyone know how to fix this?
EDIT: Here's my code: The TextView is created in a layout xml that has a GLSurfaceView (called GameView) and on top of that a TextView. Here's the xml code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="MainActivity" >
<GameView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/gv"
/>
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:textColor="@android:color/black"
android:id="@+id/tv" />
</RelativeLayout>
And here is the code in the MainActivity class onCreate method:
setContentView(R.layout.activity_main);
GameView gameView = (GameView) findViewById(R.id.gv);
TextView textView = (TextView) findViewById(R.id.tv);
The onPause, onResume, onStart, onStop methods have nothing related to the TextView. The TextView is saved into an instance variable for MainActivity and later, TextView.setText() is called to set the text of the TextView.
EDIT: I was able to fix this problem by commenting out one line: GLES20.glDeleteTextures(...) that was being called onPause() I have NO idea how this is even related or why calling this function caused that issue, but when I comment it out the problem goes away and when I bring this line back the problem comes back with it. If anyone can explain how one relates to the other, it would be greatly appreciated.
XWalkView
. Sadly theforceLayout()
call on resume does not make a difference here. – Limann