android - How to support chinese input in Libgdx -


i'm newbee in libgdx world. create stage, inside stage, create 2 actor, 1 textfield, 1 button. want textfield able support chinese input, tried, text field input has not reaction. did miss something? can take , let me know if there problem. lot!

here code:

import com.badlogic.gdx.applicationlistener; import com.badlogic.gdx.gdx; import com.badlogic.gdx.graphics.color; import com.badlogic.gdx.graphics.gl10; import com.badlogic.gdx.graphics.g2d.bitmapfont; import com.badlogic.gdx.graphics.g2d.textureatlas; import com.badlogic.gdx.graphics.g2d.textureregion; import com.badlogic.gdx.scenes.scene2d.inputevent; import com.badlogic.gdx.scenes.scene2d.inputlistener; import com.badlogic.gdx.scenes.scene2d.stage; import com.badlogic.gdx.scenes.scene2d.ui.imagebutton; import com.badlogic.gdx.scenes.scene2d.ui.textfield; import com.badlogic.gdx.scenes.scene2d.ui.textfield.textfieldlistener; import com.badlogic.gdx.scenes.scene2d.ui.textfield.textfieldstyle; import com.badlogic.gdx.scenes.scene2d.utils.textureregiondrawable;  public class textfieldlanguagetest implements applicationlistener {      private stage stage;     private bitmapfont myfont;     private textfieldstyle textfieldstyle;     private textfield textfield;     private imagebutton btn_add;     textureregion btnu;     textureregion btnd;     textureatlas  atlas;      @override     public void create() {               stage = new stage(720, 480, false);         myfont = new bitmapfont(gdx.files.internal("data/myfont.fnt"),                   gdx.files.internal("data/myfont.png"), false);         this.setbutton();         this.settextinput();         this.setlistener();          stage.addactor(btn_add);         stage.addactor(textfield);          gdx.input.setinputprocessor(stage);     }      public void setbutton(){         atlas = new textureatlas(gdx.files.internal("data/test.pack"));         btnu = atlas.findregion("addbtnu");         btnd = atlas.findregion("addbtnd");         textureregiondrawable btn_up = new textureregiondrawable(btnu);         textureregiondrawable btn_down = new textureregiondrawable(btnd);         btn_add = new imagebutton(btn_up, btn_down);         btn_add.setposition(200, 100);         btn_add.setsize(100, 50);     }      public void settextinput(){         textfieldstyle = new textfieldstyle();         textfieldstyle.font = myfont;         textfieldstyle.fontcolor = color.black;         textfield = new textfield("input here", textfieldstyle);         textfield.setposition(100,  400);         textfield.setsize(200, 60);         textfield.setmaxlength(50);     }      public void setlistener(){         btn_add.addlistener(new inputlistener(){              @override             public boolean touchdown(inputevent event, float x, float y,                     int pointer, int button) {                 // todo auto-generated method stub                 system.out.println("input text:" + textfield.gettext());                 return true;             }          });          textfield.settextfieldlistener(new textfieldlistener(){              public void keytyped (textfield textfield, char key) {                 if (key == '\n')                      textfield.getonscreenkeyboard().show(false);             }         });     }      @override     public void dispose() {      }      @override     public void render() {               gdx.gl.glclearcolor(1, 1, 1, 1);         gdx.gl.glclear(gl10.gl_color_buffer_bit);          stage.act();         stage.draw();     }      @override     public void resize(int width, int height) {     }      @override     public void pause() {     }      @override     public void resume() {     } } 

perhaps these answers can you:

libgdx draw chinese characters

special characters in libgdx's textfield not work

or this

libgdx displaying cyrillic


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -