2011-10-07 9 views
5

Tengo TableLayout, que contiene una cantidad de productos.Cada fila contiene código, cantidad de descripción, precio, valor de descuento, ..... Depende del usuario ingrese la cantidad, valor de descuento , cantidad de descuento & algunos otros valores también se calcularán.Android Softkeyboard ingrese el valor numérico en edittext muy lento

cuando el usuario haga clic en el teclado en pantalla EDITTEXT vendrá éste también está bien, trabajando bien

Mi problema es cuando el usuario pulsa las teclas numéricas muy lenta para mostrar en el EditarTexto.

Por ejemplo, he de prensa 3 de teclado, después de 7 u 8 segundos solamente se muestran en ese editText.How particular, puedo reducir esta línea de tiempo ...

Ésta es mi imagen del producto:

ProductImage

¿Alguien sugiere por qué sucede esto?

código como este:

 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"); 
        ............................. 
     } }); 
+0

verificar con filas reductoras en la tabla de rectas, ...... – viv

+0

¿Ha comprobado en el dispositivo real ...? –

+0

@Viv actualmente la primera página contiene 10 registros. No puedo reducir más porque algunos clientes tienen más de 400 registros. Entonces, si decalizamos el lado del ciclo, ¿es posible obtener el valor de las filas afuera? (Creo que no). Si declaramos afuera, entonces está bien. – Piraba

Respuesta

4

Comprobar el código de TableLayout dinámico:

main.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> 

Para añadir contenido de TableLayout usan este archivo 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> 

Después de crear filas sepearate para los diseños de agregar esto en código 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); 
    } 
}); 
} 

segundo lugar para se el bucle conseguir el clic de fila de la tabla creada dinámicamente, en la que se suman la

msg_title_text.setOnEditorActionListener(new DoneOnEditorActionListener()); 

correspondiente oyente Acción:

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; 
    } 
} 
+0

Gracias por la respuesta .... – Piraba

+0

@NagkeeranPiraba Cool – Venky

+0

+1 por un amigo mejor. –