弹出键盘问题在Android中,指定了列限制时 [英] Popup Keyboard issue in android, when column limits are specified

查看:186
本文介绍了弹出键盘问题在Android中,指定了列限制时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林工作的一个输入法Android和的任务之一就是实现一个自定义弹出键盘硬键盘按键presses。通常输入法让编辑器搞定但事情是我需要比Android支持添加更多的符号。
所以,我实现了弹出键盘,甚至有它显示以及当硬键(字符键)长pressed。

我遵循的步骤是:


  1. 创建弹出窗口。

  2. 充气其中包含一个keyboardview和关闭按钮的布局线并将其保存到一个视图对象

  3. 绑定keyboardview和关闭按钮的相关对象

  4. 在弹出的字符创建一个键盘,并将其设置为键盘键盘视图。键盘有5
  5. 的列的限制
  6. 设置线性布局的弹出窗口中的内容视图

  7. 显示弹出式窗口

问题:如果在弹出的键盘多行,我只能在最后一排的列中选择关键。即使我单击该列的第一行中的关键,在最后一排的按键被选中。
如果有人可以解释为什么发生这种情况,如何解决呢,标识AP preciate它。

code:

  PopupWindow mPopupKeyboard =新PopupWindow(this.getBaseContext());
mPopupKeyboard.setBackgroundDrawable(NULL);
如果(mPopupKeyboard!= NULL)
{
    this.dismissPopupKeyboard();
    查看mMiniKeyboardContainer = NULL;
    KeyboardView mMiniKeyboard = NULL;
    查看closeButton = NULL;
    mMiniKeyboardContainer = getLayoutInflater()膨胀(R.layout.keyboard_popup_keyboard,NU​​LL);
    mMiniKeyboard =(KeyboardView)mMiniKeyboardContainer.findViewById(R.id.popup_keyboardView);
    closeButton = mMiniKeyboardContainer.findViewById(R.id.closeButton);
    如果(closeButton!= NULL)
    {
        closeButton.setOnClickListener(新OnClickListener()
        {
            @覆盖
            公共无效的onClick(查看arg0中)
            {
                mPopupKeyboard.dismiss();
        });
    }
    mMiniKeyboard.setOnKeyboardActionListener(本);    字符串资源字符串=ABCDEFGHI;
    mMiniKeyboard.setKeyboard(新键盘(​​this.getBaseContext(),R.xml.kbd_popup_template,候补委员,3,0));
    mMiniKeyboard.setPopupParent(mCandidateView);
    mPopupKeyboard.setContentView(mMiniKeyboardContainer);
    mPopupKeyboard.setWidth(LayoutParams.WRAP_CONTENT);
    mPopupKeyboard.setHeight(LayoutParams.WRAP_CONTENT);
    mPopupKeyboard.showAtLocation(mCandidateView,Gravity.TOP,0,0);
}


解决方案

我有弹出式键盘类似的问题。我发现,这是一个问题只与Android 2.3。我唯一​​的解决方法是,以避免多行弹出式键盘。

Im working on an input method for android and one of the tasks is to implement a custom popup keyboard for hard keyboard key presses. Usually input methods let the editor handle that but the thing is I need to add more symbols than android supports. So I implemented the popup keyboard and even have it displaying well when a hard key (character key) is long pressed.

The steps I've followed are:

  1. Create popup window.
  2. Inflate a linear layout which contains a keyboardview and a close button and save it to a view object
  3. bind the keyboardview and close buttons to the relevant objects
  4. Create a keyboard for the popup characters and set it as the keyboard for the keyboard view. The keyboard has a column limit of 5.
  5. set the linear layout as the content view for the popup window
  6. Display the popup window

THE ISSUE: If there are multiple rows in the popup keyboard I am only able to select key in the last row for the column. Even if I click on the key in the first row of that column, the key in the last row gets selected. If anyone could explain why this is happening and how do I fix it, Id appreciate it.

THE CODE:

PopupWindow mPopupKeyboard = new PopupWindow(this.getBaseContext());            
mPopupKeyboard.setBackgroundDrawable(null);         


if(mPopupKeyboard != null)
{
    this.dismissPopupKeyboard();
    View mMiniKeyboardContainer = null;
    KeyboardView mMiniKeyboard = null;
    View closeButton = null;        
    mMiniKeyboardContainer = getLayoutInflater().inflate(R.layout.keyboard_popup_keyboard, null);        
    mMiniKeyboard = (KeyboardView) mMiniKeyboardContainer.findViewById(R.id.popup_keyboardView);
    closeButton = mMiniKeyboardContainer.findViewById(R.id.closeButton);
    if (closeButton != null) 
    {
        closeButton.setOnClickListener(new OnClickListener()            
        {
            @Override
            public void onClick(View arg0) 
            {
                mPopupKeyboard.dismiss();
        });
    }
    mMiniKeyboard.setOnKeyboardActionListener(this);

    String resourcestring = "abcdefghi";
    mMiniKeyboard.setKeyboard(new Keyboard(this.getBaseContext(), R.xml.kbd_popup_template, alternates, 3, 0));
    mMiniKeyboard.setPopupParent(mCandidateView);           
    mPopupKeyboard.setContentView(mMiniKeyboardContainer);
    mPopupKeyboard.setWidth(LayoutParams.WRAP_CONTENT);
    mPopupKeyboard.setHeight(LayoutParams.WRAP_CONTENT);
    mPopupKeyboard.showAtLocation(mCandidateView, Gravity.TOP, 0, 0);
}   

解决方案

I had a similar problem with popup keyboards. I found that it was a problem only with Android 2.3. My only workaround was to avoid popup keyboards with more than one row.

这篇关于弹出键盘问题在Android中,指定了列限制时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆