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

Ok. Ahora si me devuelve el dato esperado.

El único problema que me queda por resolver es que en la lista desplegable aparece todo en blanco.

El código ha quedado así:

Código:
	        baseMatriculas = openOrCreateDatabase(nombreBDMatricula, MODE_WORLD_WRITEABLE, null);   
	        Cursor cnuevo = baseMatriculas.query(tablaMatriculas, null,null,null,null,null,null);	        
            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 cursor) {
                    return cursor.getString(cursor.getColumnIndex("matricula"));
                }
            });
    			
            editMatricula = (AutoCompleteTextView) findViewById(R.id.txtMatricula);            

            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);
Saludos