我實現了ankushsachdeva emojicon project以在我的聊天應用程序中顯示emojicons。當我點擊特定聊天時,我開始聊天活動。如果我再立即點擊表情符號,ImageButton的,我做,而無需首先擴大了鍵盤,它看起來像左邊的屏幕截圖hereankushsachdeva emojicon通過軟鍵盤顯示(Android)
後記中,emojicon疊加是總是正確顯示。 (右鍵截圖)
我希望疊加層總能像右邊截圖一樣。有任何想法嗎? (在此先感謝)
ChatActivity:
private ListView listView; //contains the chatmessages and has a customAdapter
private EmojiconsPopup popUp; //emojicon-popUp
private EditText editText; //editText to capture text and emojicons
private InputMethodManager inputManager;
@Override
protected void onCreate(Bundle savedInstanceState){
listView = (ListView) findViewById(R.id.listView);
//...//
inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
popUp = new EmojiconsPopup(listView, getApplicationContext());
popUp.setSizeForSoftKeyboard();
popUp.setOnEmojiconClickedListener(new OnEmojiconClickedListener(){
@Override
public void onEmojiconClicked(Emojicon emojicon){
editText.append(emojicon.getEmoji());
}
});
popUp.setOnEmojiconBackspaceClickedListener(new OnEmojiconBackspaceClickedListener(){
@Override
public void onEmojiconBackspaceClicked(View v){
KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL);
editText.dispatchKeyEvent(event);
}
});
popUp.setOnSoftKeyboardOpenCloseListener(new OnSoftKeyboardOpenCloseListener(){
@Override
public void onKeyboardOpen(int keyBoardHeight){
}
@Override
public void onKeyboardClose(){
if (popUp.isShowing())
popUp.dismiss();
}
});
}
//called when the emojicon button is clicked
public void onEmojiButtonClicked(View view){
if (!popUp.isShowing()){
inputManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
popUp.showAtBottom(); //show popUp with emojicons
}else if(popUp.isShowing()){
popUp.dismiss(); // hide popUp with emojicons
}
}
工程就像一個魅力,謝謝! – mtosch 2015-04-06 16:02:04