Ver Mensaje Individual
  #13 (permalink)  
Antiguo 28/05/2012, 07:15
ci2000
 
Fecha de Ingreso: abril-2005
Mensajes: 483
Antigüedad: 19 años
Puntos: 3
Respuesta: Mostrar tabla en AutoCompleteTextView

Otro problema que tengo es que despliega todas las matrículas al presionar cualquier letra, es decir tengo matrículas que comienzan con R y otras con W. Si presiono por ejemplo la X me despliega todas las matrículas comenzadas con R y con W.

Le hice otros cambios al código pero todo sigue con los mismos problemas.

Código:
            editMatricula = (AutoCompleteTextView) findViewById(R.id.txtMatricula); 

	        baseMatriculas = openOrCreateDatabase(nombreBDMatricula, MODE_WORLD_WRITEABLE, null);   
	        String []Columnas = new String[]{"_id","matricula"};
	        Cursor cnuevo = baseMatriculas.query(tablaMatriculas, Columnas,null,null,null,null,null);
	        this.startManagingCursor(cnuevo);
            SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,android.R.layout.simple_dropdown_item_1line, cnuevo, new String[] {"matricula"}, new int[] {R.id.txtMatricula});
	        
            adapter.setCursorToStringConverter(new CursorToStringConverter() {            	 
                public CharSequence convertToString(Cursor cnuevo) {
                    return cnuevo.getString(cnuevo.getColumnIndex("matricula"));
                }
            });	        
           
            editMatricula.addTextChangedListener(new TextWatcher() 
            {
        		 public void afterTextChanged(Editable s) {

        		     String filtered_str = s.toString();
        		     	 AvisoError = "NO";
        		         if (filtered_str.matches(".*[^A-Z^0-9|-].*")) {
        		         AvisoError = "SI";
        		         //filtered_str = filtered_str.replaceAll("[^A-Z^0-9]", "");

        		         //s.clear();

        		         // s.insert(0, filtered_str);
        		         AlertDialog.Builder dialogo1 = new AlertDialog.Builder(d_matricula.this);  
        		         dialogo1.setTitle("¡Atención!");  
        		         dialogo1.setMessage("Está permitido ingresar sólo letras mayúsculas, números y guion."); 
        		         dialogo1.setNeutralButton("Aceptar",null);
        		         dialogo1.show();	
        		         //Toast.makeText(getApplicationContext(), "Ingresó un caracter no válido", Toast.LENGTH_SHORT).show();

        		     }

        		 }

        		     public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

        		     public void onTextChanged(CharSequence s, int start, int before, int count) {}
        	});
            

            editMatricula.setThreshold(1);
            editMatricula.setAdapter(adapter);
El xml es:

Código:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/txtOperario"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10px"
        android:gravity="center"
        android:text=""
        android:textColor="#ffffff"
        android:textSize="24px" />
        
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30px"
        android:gravity="center"
        android:text="Ingrese matrícula del camión"
        android:textColor="#ffffff"
        android:textSize="24px" />
    
    <AutoCompleteTextView 
        android:id="@+id/txtMatricula"
        android:layout_width="fill_parent"
        android:layout_height="100px"
        android:layout_marginTop="10px"
		android:textSize="44sp"
		android:textStyle="bold"
		android:gravity="center"
		android:singleLine="true"
		android:capitalize="characters" >

        <requestFocus />

    </AutoCompleteTextView>
        
    <Button android:id="@+id/botonInicio"
        android:layout_width="fill_parent"
        android:layout_height="100px"
        android:textSize="30sp"
        android:text="" />

    <TableRow>
    <Button android:id="@+id/botonMatricula1"
        android:layout_width="235px"
        android:layout_height="100px"
        android:textSize="30sp"
        android:text="TRP4567" />

    <Button android:id="@+id/botonMatricula2"
        android:layout_width="235px"
        android:layout_height="100px"
        android:textSize="30sp"
        android:text="RTP489" />
     </TableRow>

    <TableRow>
    <Button android:id="@+id/botonMatricula3"
        android:layout_width="235px"
        android:layout_height="100px"
        android:textSize="30sp"
        android:text="TRP4567" />

    <Button android:id="@+id/botonMatricula4"
        android:layout_width="235px"
        android:layout_height="100px"
        android:textSize="30sp"
        android:text="RTP489" />
    </TableRow>
</TableLayout>
Saludos