Android Softkeyboard将数值输入edittext非常慢

Pir*_*aba 5 android soft-keyboard

我有TableLayout,其中包含多个产品.每行包含代码,描述数量,价格,折扣价值,.....取决于用户输入数量,折扣价值,折扣数量和其他一些值也会计算.

当用户点击editText软键盘时,这个也可以,工作正常

我的问题是当用户按下数字键非常慢以在EditText中显示.

例如我从键盘按3,经过7或8秒后只显示在特定的editText中.如何缩短此时间线...

这是我的产品图片:

ProductImage

请有人建议为什么会这样?

像这样的代码:

     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");
                    .............................
        } });
Run Code Online (Sandbox Code Playgroud)

Ven*_*nky 4

检查动态表格布局的代码:

主要.xml:

<?xml version="1.0" encoding="utf-8"?>
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="#C0C0C0">

  <RelativeLayout
     android:layout_width="fill_parent" android:paddingBottom="20dip"
     android:layout_height="fill_parent"
     android:background="#C0C0C0">

   <TableLayout android:id="@+id/contact_table"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_below="@+id/contact_info_title"
      android:layout_marginTop="10dp"
      android:background="@drawable/bgwhite_selector">
      </TableLayout>
 </RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

要添加 TableLayout 的内容,请使用此 xml 文件:

<?xml version="1.0" encoding="utf-8"?>
      <LinearLayout   xmlns:android="http://schemas.android.com/apk/res/android"         android:id="@+id/lays"
            android:layout_width="wrap_content" android:background="@color/white"
            android:layout_height="wrap_content" android:orientation="vertical"> 

<TableRow    android:background="@color/white" android:layout_width="wrap_content"
            android:layout_height="wrap_content">

<TextView   android:text=">" 
            android:textSize="18dip" android:textStyle="bold"  android:layout_width="wrap_content" 
            android:layout_height="wrap_content" android:id="@+id/arrowText"/> 
  </TableRow>

 </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

为布局创建单独的行后,在 Java 代码中添加以下内容:

contact_table = (TableLayout)findViewById(R.id.contact_table);

LayoutInflater inflater = getLayoutInflater();

for(int i = 0; i < contact_count ; i++) {
LinearLayout row = (LinearLayout)inflater.inflate(R.layout.table_row,contact_table, false);
TextView text = (TextView)row.findViewById(R.id.text);
text.setText(list_data.get(i).summary);
contact_table.addView(row);
  }

 for(int i=0;i<contact_table.getChildCount();i++){ 
final View row=contact_table.getChildAt(i);
row.setOnClickListener(new OnClickListener(){
    @Override
    public void onClick(View v){
        // TODO Auto-generated method stub
        row_id=contact_table.indexOfChild(row);
    }
});
}
Run Code Online (Sandbox Code Playgroud)

第二个 for 是循环单击动态创建的表行,其中添加

    msg_title_text.setOnEditorActionListener(new DoneOnEditorActionListener());
Run Code Online (Sandbox Code Playgroud)

对应的Action监听器:

    class DoneOnEditorActionListener implements OnEditorActionListener {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            Log.v("*****************************", "Clicked");

            return true;    
        }
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)