Swapping views disables the soft keyboard?

Problems with Canvas, OpenGL, etc...

Swapping views disables the soft keyboard?

Postby jvff » Tue Jan 25, 2011 4:11 pm

Hi,

sorry if this isn't the best board to ask this, but I thought it would be since my objective is to display the soft keyboard over a GLSurfaceView. Why does swapping a view (in my case, two GLSurfaceViews) prevent me from openning the software keyboard? Here is an example snippet (coded for Froyo):

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package jvff.glsoftkey;
  2.  
  3. import javax.microedition.khronos.egl.EGLConfig;
  4. import javax.microedition.khronos.opengles.GL10;
  5.  
  6. import android.content.Context;
  7. import android.opengl.GLSurfaceView;
  8. import android.opengl.GLSurfaceView.Renderer;
  9. import android.util.AttributeSet;
  10.  
  11. public class GLView extends GLSurfaceView implements Renderer {
  12.     Context context;
  13.    
  14.     public GLView(Context context) {
  15.         super(context);
  16.        
  17.         this.context = context;
  18.        
  19.         setRenderer(this);
  20.         setFocusable(true);
  21.         setFocusableInTouchMode(true);
  22.     }
  23.  
  24.     public GLView(Context context, AttributeSet attrs) {
  25.         super(context, attrs);
  26.     }
  27.  
  28.     @Override
  29.     public void onDrawFrame(GL10 gl) {
  30.         gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
  31.     }
  32.  
  33.     @Override
  34.     public void onSurfaceChanged(GL10 arg0, int arg1, int arg2) {
  35.     }
  36.  
  37.     @Override
  38.     public void onSurfaceCreated(GL10 gl, EGLConfig config) {
  39.         gl.glClearColor(0.f, 0.f, 1.f, 1.f);
  40.     }
  41. }
  42.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package jvff.glsoftkey;
  2.  
  3. import android.app.Activity;
  4. import android.content.Context;
  5. import android.os.Bundle;
  6. import android.view.MotionEvent;
  7. import android.view.Window;
  8. import android.view.WindowManager;
  9. import android.view.inputmethod.InputMethodManager;
  10.  
  11. public class GLSoftKeyTest extends Activity {
  12.     private GLView view;
  13.    
  14.     @Override
  15.     public void onCreate(Bundle savedInstanceState) {
  16.         super.onCreate(savedInstanceState);
  17.        
  18.         view = new GLView(this);
  19.         setContentView(view);
  20.     }
  21.    
  22.     @Override
  23.     public void onBackPressed() {
  24.         view = new GLView(this);
  25.         setContentView(view);
  26.     }
  27.    
  28.     @Override
  29.     public boolean onTouchEvent(MotionEvent event) {
  30.         if (event.getAction() == MotionEvent.ACTION_DOWN) {
  31.             ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view, 0);
  32.             return true;
  33.         }
  34.        
  35.         return false;
  36.     }
  37. }
  38.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


When it opens initially, it works correctly. After pressing the back button (sorry for the non-intuitiveness of using the back key), it stops working. What am I missing to make it work? Thank you,

Janito
jvff
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Jan 25, 2011 3:55 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 1 guest