Hi guys 25 days ago I asked explaination about refreshing of listview withot calling notifyDataSetChanged():
Listview refresh without notifyDataSetChange
Now the question is connected to the last because I noticed that listview doesn't refresh without notify method but only when I press back button to hide softkeyboard. So when I add an item to listview, if I call notifyDataSetChanged() and the softkeyboard is opened I see immediatelly adding result, if I haven't notify and add new item to listview I see adding result only when press back button to hide softkeyboard.
I surfed on internet to understand this behaviour but nothing helped me. Can anyone explain me if hiding softkeyboard causes refresh of something?
My code:
btnAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Toast.makeText(getActivity(), txtQuantita.getText(), Toast.LENGTH_LONG).show();
if (!txtQuantita.getText().toString().equals(""))
{
row.setQuantity(Double.parseDouble(txtQuantita.getText().toString()));
new InsertShopRowAsync(getActivity(), mListFoodsIn, wherehouseAdapter, row, false).execute();
}
//InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
//inputMethodManager.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
Async add:
public InsertShopRowAsync(Context ct, ArrayList<Wherehouse> list, wherehouseAdapter adapter, Wherehouse newRow, boolean updateQuery) {
mContext = ct;
mList = list;
newItem = newRow;
mAdapter = adapter;
db = new DBManager(ct);
queryUpdate = updateQuery;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Boolean doInBackground(Wherehouse... wherehouses) {
int index = GetItemAtIndex(newItem);
if (index > -1){
//Ho un item uguale, lo aggiorno --> qui aggiorno solo incrementando le qta al contrario della dailymealsfragment dove rimpiazzio direttamente la routine
mList.get(index).setQuantity( mList.get(index).getQuantity() + newItem.getQuantity());
}else{
mList.add(newItem);
}
boolean result = db.InsertIntoWherehouse(newItem);
return result;
}
@Override
protected void onPostExecute(Boolean aLong) {
super.onPostExecute(aLong);
//mAdapter.notifyDataSetChanged();
asyncInsertedResult = aLong;
}