Android EditText光标不可用

时间:2012-09-22 16:18:29

标签: android android-edittext android-cursor

您好我正在尝试使用自己的键盘视图,而不是默认设置。

在搜索区域(Edittext)中,我无法使用默认光标

我正在研究

上提供的键盘视图示例

Android-KeyboardView-Example

活动源代码

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);
        }
    }
}

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

1 个答案:

答案 0 :(得分:0)

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