gpt4 book ai didi

android - 每次单击按钮时如何取消键盘上的白色空白

转载 作者:行者123 更新时间:2023-11-30 00:58:12 26 4
gpt4 key购买 nike

嘿,当我点击自定义键盘时,它会显示这个空白的东西,我不想每次点击按钮时都出现这个东西,如果你看到它,我怎么能删除它在图片上的东西,你会明白的我更多,感谢您的帮助

enter image description here

CustomKeyboardView.class

public class CustomKeyboardView extends KeyboardView {

public CustomKeyboardView(Context context, AttributeSet attrs) {

super(context, attrs);
}

public void showWithAnimation(Animation animation) {
animation.setAnimationListener(new AnimationListener() {

@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub

}

@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub

}

@Override
public void onAnimationEnd(Animation animation) {
setVisibility(View.VISIBLE);
}
});

startAnimation(animation);
}

mainactivity.class

  private CustomKeyboardView mKeyboardView;
private EditText 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(KeyboardWidgetActivity.this,
R.anim.slide_in_bottom);
mKeyboardView.showWithAnimation(animation);
}
}

BasicOnKeyboardActionListener.class

public class BasicOnKeyboardActionListener implements KeyboardView.OnKeyboardActionListener {

private Activity mTargetActivity;



public BasicOnKeyboardActionListener(Activity targetActivity) {
mTargetActivity = targetActivity;
}

@Override
public void swipeUp() {
// TODO Auto-generated method stub

}

@Override
public void swipeRight() {
// TODO Auto-generated method stub

}

@Override
public void swipeLeft() {
// TODO Auto-generated method stub

}

@Override
public void swipeDown() {
// TODO Auto-generated method stub

}

@Override
public void onText(CharSequence text) {
// TODO Auto-generated method stub

}

@Override
public void onRelease(int primaryCode) {
// TODO Auto-generated method stub

}

@Override
public void onPress(int primaryCode) {
// TODO Auto-generated method stub

}

@Override
public void onKey(int primaryCode, int[] keyCodes) {
long eventTime = System.currentTimeMillis();
KeyEvent event = new KeyEvent(eventTime, eventTime,
KeyEvent.ACTION_DOWN, primaryCode, 0, 0, 0, 0,
KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE);

mTargetActivity.dispatchKeyEvent(event);
}

最佳答案

设置

mKeyboardView.setPreviewEnabled(false);

为您的键盘 View 设置 findViewById 之后

关于android - 每次单击按钮时如何取消键盘上的白色空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39832040/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com