mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4902 from Dhilan007/develop_crash
fix TextInput not show IME on android.
This commit is contained in:
commit
e4bec7d1ef
|
@ -23,6 +23,7 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
package org.cocos2dx.lib;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
|
@ -59,9 +60,11 @@ public class Cocos2dxEditText extends EditText {
|
|||
this.setOnEditorActionListener(this.mTextWatcher);
|
||||
|
||||
ViewGroup.LayoutParams layout =
|
||||
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
|
||||
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
this.setLayoutParams(layout);
|
||||
|
||||
Activity activity = (Activity)context;
|
||||
activity.addContentView(this, layout);
|
||||
}
|
||||
|
||||
// ===========================================================
|
||||
|
@ -84,7 +87,7 @@ public class Cocos2dxEditText extends EditText {
|
|||
this.removeTextChangedListener(mTextWatcher);
|
||||
final InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(this.getWindowToken(), 0);
|
||||
Cocos2dxHelper.nativeRequestFocus();
|
||||
//Cocos2dxHelper.nativeRequestFocus();
|
||||
}
|
||||
|
||||
public void openIMEKeyboard() {
|
||||
|
@ -96,7 +99,7 @@ public class Cocos2dxEditText extends EditText {
|
|||
this.addTextChangedListener(mTextWatcher);
|
||||
|
||||
final InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT);
|
||||
imm.showSoftInput(this, InputMethodManager.SHOW_FORCED);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -105,7 +108,7 @@ public class Cocos2dxEditText extends EditText {
|
|||
|
||||
/* Let GlSurfaceView get focus if back key is input. */
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
this.requestFocus();
|
||||
//Cocos2dxHelper.nativeRequestFocus();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -189,7 +192,6 @@ class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListener {
|
|||
|
||||
@Override
|
||||
public void onTextChanged(final CharSequence pCharSequence, final int start, final int before, final int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue