estoy usando el siguiente código para establecer el adaptador (SimpleCursorAdapter) para un AutoCompleteTextViewAutoCompleteTextView pantallas 'android.database.sqlite.SQLiteCursor @' ... después de hacer la selección
mComment = (AutoCompleteTextView) findViewById(R.id.comment);
Cursor cComments = myAdapter.getDistinctComments();
scaComments = new SimpleCursorAdapter(this,R.layout.auto_complete_item,cComments,new String[] {DBAdapter.KEY_LOG_COMMENT},new int[]{R.id.text1});
mComment.setAdapter(scaComments);
auto_complete_item.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
y thi es el XML para el control real
<AutoCompleteTextView
android:id="@+id/comment"
android:hint="@string/COMMENT"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18dp"/>
el d ropdown parece funcionar correctamente y muestra una lista de elementos. Cuando hago una selección de la lista, obtengo un objeto sqlite ('android.database.sqlite.SQLiteCursor @' ...) en la vista de texto. ¿Alguien sabe qué podría causar esto o cómo resolver esto?
gracias
Ok soy capaz de enganchar en el caso OnItemClick, pero la porción TextView.setText() del widget AutoCompleteTextView se actualiza después de este punto. El evento OnItemSelected() nunca se dispara y el evento onNothingSelected() se activa cuando se muestran los elementos desplegables por primera vez.
mComment.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
SimpleCursorAdapter sca = (SimpleCursorAdapter) arg0.getAdapter();
String str = getSpinnerSelectedValue(sca,arg2,"comment");
TextView txt = (TextView) arg1;
txt.setText(str);
Toast.makeText(ctx, "onItemClick", Toast.LENGTH_SHORT).show();
}
});
mComment.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
Toast.makeText(ctx, "onItemSelected", Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
Toast.makeText(ctx, "onNothingSelected", Toast.LENGTH_SHORT).show();
}
});
¿Alguien tiene alguna idea sobre cómo anular la actualización de TextView?
gracias
Patrick
Sí, estás en lo correcto. Simplemente selecciono una de las opciones del control giratorio que se crea como parte de AutoCompleteTextView. ¿Dónde o cómo intercepto la función para procesar la selección? use getString() en el cursor, antes de que se establezca como el texto del control. También agregaré mi xml. – bugzy
"¿Dónde o cómo interceptar la función para procesar la selección?" - ya lo está haciendo. En algún lugar, estás llamando 'setText()' en el TextView. Edita ese código. – CommonsWare
Ese es el punto ... No lo soy. Es el comportamiento integrado del widget AutoCompleteTextView que está rellenando la porción TextView del widget AutoCompleteTextView. – bugzy