62,615
社区成员
发帖
与我相关
我的任务
分享
<?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" >
<EditText
android:id="@+id/textField"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</EditText>
<com.GclFramework.GclGLSurfaceView
android:id="@+id/Gcl_gl_surfaceview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
final LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams params = new LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
layout.setLayoutParams(params);
setContentView(layout);
mGLView = new GclGLSurfaceView(this);
mGLView.SetResPath(sResPath);
LayoutParams paramsView = new LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
mGLView.setLayoutParams(paramsView);
edtInput = new EditText(this);
LayoutParams parEdit = new LayoutParams(LinearLayout.LayoutParams.FILL_PARENT
,LinearLayout.LayoutParams.FILL_PARENT);
edtInput.setLayoutParams(parEdit);
mGLView.setTextField(edtInput);
GclGLSurfaceView.mainView=mGLView;
layout.addView(mGLView);
//如果不动态创建,使用下面注释的代码,是可以正常显示出编辑框和输入法
/* setContentView(R.layout.main);
mGLView = (GclGLSurfaceView) findViewById(R.id.QJP_gl_surfaceview);
if (null == mGLView)
mGLView = GclGLSurfaceView.mainView;
mGLView.SetResPath(sResPath);
EditText edit = (EditText) findViewById(R.id.textField);
if (edit != null)
mGLView.setTextField(edit);
*/
public void setTextField(TextView view) {
mTextField = view;
if (null != mTextField && null != textInputWraper) {
LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) mTextField.getLayoutParams();
linearParams.height = 0;
mTextField.setLayoutParams(linearParams);
mTextField.setOnEditorActionListener(textInputWraper);
this.requestFocus();
}
}
case HANDLER_OPEN_IME_KEYBOARD:
if (null != mTextField && mTextField.requestFocus()) {
mTextField.removeTextChangedListener(textInputWraper);
mTextField.setText("");
String text = (String)msg.obj;
mTextField.append(text);
mTextField.setHint("<请输入>");
textInputWraper.setOriginText(text);
mTextField.addTextChangedListener(textInputWraper);
Context c=mainView.getContext();
InputMethodManager imm = (InputMethodManager)c.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mTextField, 0);
Log.d("GLSurfaceView", "showSoftInput");
// ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
break;