我有一个TableLayout,其中包含多个产品。每行都包含代码、描述、数量、价格、折扣值等内容...根据用户输入的数量、折扣值、折扣数量和其他一些值也会进行计算。
当用户点击editText时,软键盘会出现,这也可以正常工作。
我的问题是,当用户按数字键时,EditText中显示得非常缓慢。
例如,我从键盘上按下3键,只有在7或8秒后它才显示在那个特定的EditText中。我该如何缩短这个时间线...
这是我的产品图片:
请有经验的人指导一下,为什么会发生这种情况?
代码类似于这样:
for (int i = initil; i <end; i++) {
.............
............
final EditText txtQty = new EditText(this);
txtQty.setHeight(1);
txtQty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 42));
txtQty.setInputType(InputType.TYPE_CLASS_PHONE);
txtQty.setImeOptions(EditorInfo.IME_ACTION_DONE);
txtQty.setImeOptions(EditorInfo.IME_ACTION_NEXT);
txtQty.setSelectAllOnFocus(true);
txtQty.setTextSize(9);
txtQty.setHint("0.0");
// txtQty.setOnEditorActionListener(new DoneOnEditorActionListener());
// txtQty.setHighlightColor(R.color.green);
tr.addView(txtQty);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(txtQty, InputMethodManager.SHOW_IMPLICIT);
mgr.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,InputMethodManager.HIDE_IMPLICIT_ONLY);
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(txtQty.getWindowToken(), 0);
txtQty.setOnEditorActionListener( new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
Log.i("KeyBoard" ,"Inside the Edit Text");
.............................
} });