he encontrado la razón por la cual es que se llama a getView() cuando intento editar algo, por lo que los datos del DataAdapter se cargan & mis cambios editados desaparecen.
EDIT:
he observado una cosa, si hay pocas filas en la vista de lista entonces su bien, pero si hay muchas filas, que la vista de lista no se puede mostrar en el visibles pantalla (la barra de desplazamiento aparece para desplazarse a otros registros), luego ¡surge el problema!
Estoy trabajando en el proyecto donde hemos implementado un INLINE EDITING using ListView, es decir, los datos se pueden editar dentro de la vista de lista.
Tengo un xml definido para cada artículo/fila de ese ListView. Estoy usando Custom DataAdapter para vincular los datos con ListView.
La primera vez que cargué esa actividad, se carga el ListView, puedo editar los datos &, funciona bien. Cuando se edita algo, los cambios se guardan en la base de datos SQLite, tengo un botón para este fin.
Ahora el problema es que después de guardar los datos POR PRIMERA VEZ & la vista de lista se carga de nuevo, no puedo editar los datos más. Cuando trato de editar los datos aparece el teclado & y luego desaparece automáticamente & el DATO ENTRADO también desaparece. Por favor, mira las capturas de pantalla.
¿Puede alguien ayudarme a resolver este problema?
mi clase adaptador personalizado:
public class QuestionAdapter extends ArrayAdapter<QuestionEntity> {
private ArrayList<QuestionEntity> items;
private Context CurrentContext;
private QuestionEntity CurrentItem;
private Cursor OptionsCursor;
public QuestionAdapter(Context context, ArrayList<QuestionEntity> items, Cursor curOptions)
{
super(context, R.layout.grid_item, items);
this.CurrentContext = context;
this.items = items;
this.OptionsCursor = curOptions;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
//verify that the items list is still valid since
//the list may have been cleared during an update
if ((items == null) || ((position + 1) > items.size()))
return convertView; //Can't extract item
CurrentItem = items.get(position);
if(convertView == null)
{
LayoutInflater inflater = LayoutInflater.from(CurrentContext);
convertView = inflater.inflate(R.layout.grid_item, null);
}
if (convertView != null)
{
TextView txtQuestion = (TextView) convertView.findViewById(R.id.txtQuestion);
txtQuestion.setText(CurrentItem.getTitle());
Spinner cmbOptions = (Spinner)convertView.findViewById(R.id.cmbOptions);
/*
* Load the options from OptionsCursor
*/
LoadOptions(cmbOptions);
/*
* Attach onItemClick event with cmbOptions
* When the user change the option we will populate the comments based on the option
*/
cmbOptions.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id)
{
try
{
//If MyCondition is true show msg to user.
}
catch(Exception ex)
{
ex.toString();
}
}
});
}
return convertView;
}
private void LoadOptions(Spinner iacOptions)
{
//Load data in the spinner using the OptionsCursor
}
}
http://www.youtube.com/watch?v=wDBM6wVEO70 – Selvin