EDIT:
I found the reason getView () is called when I try to edit something, so the data from the DataAdapter is loaded and my changed changes disappear.
EDIT:
I noticed one thing: if there are several lines in the list, then OK, but if there are many lines whose list cannot be displayed in a visible screen (the scroll bar is displayed to scroll to other entries), then the problem arises !!
I am working on a project where we implemented INLINE EDITING using a ListView , that is, the data can be edited inside the list.
I have a specific xml for each item / row of this ListView. I am using a Custom DataAdapter to bind data using a ListView.
When I first load this activity, the ListView loads, I can edit the data, and it works great. When something is edited, the changes are saved in the SQLite database, I have a button for this purpose.
Now the problem is that after the data is saved VERY FIRST TIME and the list is loaded again, I can no longer edit the data. When I try to edit the data, the keyboard appears and then automatically disappears, and the entered data also disappears. See screenshots.
Can someone help me solve this problem?
my custom adapter class:
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)
{
if ((items == null) || ((position + 1) > items.size()))
return convertView;
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);
LoadOptions(cmbOptions);
cmbOptions.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id)
{
try
{
}
catch(Exception ex)
{
ex.toString();
}
}
});
}
return convertView;
}
private void LoadOptions(Spinner iacOptions)
{
}
}
