0

您好我正在尝试做一个应用程序,它使用自己的键盘视图而不是默认值。

在搜索区域(Edittext)我不能使用默认光标

我正在研究一个可用的键盘视图示例

Android-KeyboardView-示例

活动源代码

package it.anddev.tutorial;

import android.app.Activity;

import android.inputmethodservice.Keyboard;

import android.os.Bundle;

import android.view.MotionEvent;

import android.view.View;

import android.view.animation.Animation;

import android.view.animation.AnimationUtils;

import android.widget.EditText;

public class KeyboardWidgetTutorialActivity extends Activity {

    private CustomKeyboardView mKeyboardView;
    private View mTargetView;
    private Keyboard mKeyboard;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        mKeyboard = new Keyboard(this, R.xml.keyboard);
        mTargetView = (EditText) findViewById(R.id.target);
        mTargetView.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                showKeyboardWithAnimation();
                return true;
            }
        });

        mKeyboardView = (CustomKeyboardView) findViewById(R.id.keyboard_view);
        mKeyboardView.setKeyboard(mKeyboard);
        mKeyboardView
                .setOnKeyboardActionListener(new BasicOnKeyboardActionListener(
                        this));
    }

    private void showKeyboardWithAnimation() {
        if (mKeyboardView.getVisibility() == View.GONE) {
            Animation animation = AnimationUtils
                    .loadAnimation(KeyboardWidgetTutorialActivity.this,
                            R.anim.slide_in_bottom);
            mKeyboardView.showWithAnimation(animation);
        }
    }
}

键盘视图是否会阻止该未来或如何启用它?

4

1 回答 1

0

很可能您的布局参数中没有 android:focusable="true" 。请使用受影响的 EditText 字段发布您的布局 XML。

于 2013-01-31T01:36:10.623 回答